jquery获取里面的文本< li> [英] jquery get the text inside <li>
本文介绍了jquery获取里面的文本< li>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个div
< div class =RestauranstSection>
< label>
餐厅:
< / label>
< input type =text/>
< input type =buttonvalue =Search/>
< ul>
<?php while($ row = $ restaurants-> fetch()){
?>
< li id =<?php echo $ row ['ID'];?>>
<?php echo $ row ['name']; ?>
< / li>
<?php}?>
< / ul>
< / div>
我想在按任何 li
元素时('click','li',function())来提醒其文本,
$(。RestauranstSection {});
怎么样?
解决方案('click','li',function(){
alert($(this).text。)($ .c $ c> $(。RestauranstSection ());
});
alert($(this).text。)($ .c $ c> $(。RestauranstSection ());
});
I have this div
<div class="RestauranstSection">
<label>
Restaurant:
</label>
<input type="text"/>
<input type="button" value="Search"/>
<ul>
<?php while ($row = $restaurants->fetch()) {
?>
<li id="<?php echo $row['ID']; ?>">
<?php echo $row['name']; ?>
</li>
<?php } ?>
</ul>
</div>
I want when press on any li
elements to alert its text,
$(".RestauranstSection").on('click','li',function (){});
how please?
解决方案
$(".RestauranstSection").on('click','li',function (){
alert($(this).text());
});
这篇关于jquery获取里面的文本< li>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文