我有这个
<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>
我希望当点击任何一个li
元素时,能够弹出该元素的文本内容。
$(".RestauranstSection").on('click','li',function (){});
怎么做呢?
jquery获取元素文本
会将http://api.jquery.com/text/作为第一个结果呈现,同时还有其他相关的SO问题。 - Felix Kling