这只是一个简单的例子:
<p>
<span class="example"></span>
<input type="text" name="e_name" id="e_id />
</p>
<script type="text/javascript">
$('input').click(function(){
$(this).parent().children('span').text('Suprise!');
}
</script>
我可以使用什么来代替parent().children()?
我认为这是一段不太优雅的代码。是否有任何函数例如:$(这).fun(‘span’).text(‘just better');??
https://stackoverflow.com/questions/6155638
复制相似问题