87,989
社区成员
发帖
与我相关
我的任务
分享
<p>aa</p>
<p>bb</p>
<p>cc</p>
<p>dd</p>
<p>ee</p>
<script type="text/javascript">
$(function(){
$("p").each(function(){
alert($(this).text());
})
});
</script>
二
<button type="button">Button 1</button>
<button type="button">Button 2</button>
<button type="button">Button 3</button>
<button type="button">Button 4</button>
<button type="button">Button 5</button>
<script type="text/javascript">
$(function(){
$("button").click(function(){
alert($(this).text());
})
});
</script>
三
<button type="button" id="button1">显示</button>
<button type="button" id="button2">隐藏</button>
<div id="dd">div内容</div>
<script type="text/javascript">
$(function(){
$("#button1").click(function(){
$("#dd").show();
})
$("#button2").click(function(){
$("#dd").hide();
})
});
</script>
四
<select id="sel">
<option selected="selected">red</option>
<option>blue</option>
<option>yellow</option>
</select>
<div id="dd" style="background-color: red;">div内容</div>
<script type="text/javascript">
$(function(){
$("#sel").change(function(event){
$("#dd").css("background-color",$(this).find(":selected").text());
});
});
</script>