我想为用户创建一个搜索输入,以便快速找到我学校的老师.
以上是一个包含很多教师的水平滚动条.滚动条中的每个教师都被包含在一个单独的div中staff-container
.
<div class="staff-container">
<div class="staff">
<div class="staff-picture">
<img src="img/people/teachers/aiello.png" alt="" />
</div>
<p><span class="bold">Mrs. Aiello</span><br />
Ext. 13328<br />
Room 328/323<br />
<a href="mailto:asusan@wcskids.net">asusan@wcskids.net</a></p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
以上是staff-container
艾哈迈德先生.每位教师都有与HTML相同的结构.
当我在搜索中键入教师姓名并单击搜索按钮时,我希望发生以下情况.
我想通过使用JQuery staff-container
来隐藏与搜索词不匹配的所有内容display:none;
.
我希望搜索只查找教师姓名.换句话说,搜索中只应查找<span class="bold">teacher</span>
每个中staff-container
的内容.
如果没有教师匹配搜索词,我希望显示所有教师.如果没有搜索到任何内容,我希望显示所有教师.
搜索HTML:
<div class="search-container">
<form class="form-search form-inline">
<input type="text" class="input-medium search-query" placeholder="Search">
<button type="submit" class="btn">Search</button>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
这是一个非常简单的小提琴
查看我要添加搜索的网页.它还没有搜索它.
对不起,如果我问一个问题太大的悲伤面孔,我只需要帮助,因为我从来没有在jquery中搜索过.
编辑删除downvote
这是我的问题.我正在创建一个有"新闻"标签的网站.我想要的新闻标签是来自其他新闻网站的更新内容.
有没有办法获取在其他网站上发布的纯文本,将其发布在我网站的新闻标签上,并在网站发布新内容时自动更新?任何人都可以把我推向正确的方向,这样我就可以学习如何做到这一点?
我非常了解HTML,但缺乏PHP和Javascript技能.为了解决这个问题,我需要学习什么?
我在互联网上看过这么多次.人们说不要在编程语言中重复自己.我为我的网页编写了这个脚本,但我重复了一遍.
这真的很重要吗?
我应该做一个功能吗?
我该怎么做?
var active = '.teachers';
var disabled = '.teacher-link';
var width = $('.teachers .staff-outer-container').children().size() * 180;
$('.staff-outer-container').css('width', width + 'px');
$('.teacher-link').click(function() {
if (active != '.teachers') {
$(active).hide();
active = '.teachers';
$(active).show();
width = $('.teachers .staff-outer-container').children().size() * 180;
$('.teachers .staff-outer-container').css('width', width + 'px');
$(disabled).removeClass('active').addClass('clickable');
disabled = this;
$(disabled).removeClass('clickable').addClass('active');
$('#type').text('Teachers');
}
});
$('.admin-link').click(function() {
if (active != '.administrators') {
$(active).hide();
active = '.administrators';
$(active).show();
width = $('.administrators .staff-outer-container').children().size() * 180;
$('.administrators .staff-outer-container').css('width', width + 'px');
$(disabled).removeClass('active').addClass('clickable');
disabled = …
Run Code Online (Sandbox Code Playgroud) 我在另一个div里面有一个div.外部div具有百分比宽度(80%),并且我希望内部div的宽度比外部div的宽度小30px.我该怎么做呢?我假设我需要使用javascript?提前致谢.
我想jQuery来添加一个类.pointer
来.staff-container
,如果<a href="">
中存在.staff-picture
.
我的Jquery:
if($('.staff-container').find('.staff-picture').closest('a').length) {
$(this).addClass('pointer');
}
Run Code Online (Sandbox Code Playgroud)
上面的jquery没有添加任何类,我做错了什么?
我的Css:
.pointer {
cursor:pointer !important;
}
Run Code Online (Sandbox Code Playgroud)
我的HTML:
<div class="teachers">
<div class="span12">
<div class="scroll transparent">
<div class="staff-outer-container">
<div class="staff-container">
<div class="staff">
<div class="staff-picture">
<a href="http://ahmedmathematics.weebly.com/index.html" target="_blank"><img src="img/people/teachers/ahmed.png" /></a>
</div>
<p><span class="bold">Mr. Ahmed</span><br />
Ext. 13417<br />
Room 417/323<br />
<a href="mailto:Ahmed@wcskids.net">Ahmed@wcskids.net</a></p>
</div>
</div>
<div class="staff-container">
<div class="staff">
<div class="staff-picture">
<img src="img/people/teachers/aiello.png" />
</div>
<p><span class="bold">Mr. Aiello</span><br />
Ext. 13328<br />
Room 328/323<br />
<a href="mailto:ASusan@wcskids.net">ASusan@wcskids.net</a></p> …
Run Code Online (Sandbox Code Playgroud)