Atu*_*tul 3 html javascript css jquery
我想做这样的事情:
<div class="show" >Element 1</div>
<div class="show" >Element 2</div>
<div class="show" >Element 3</div>
$("div.show").click(function () {
$current_show = $(this);
$("div.show").each(function () {
if ($(this) != $current_show ) //here i want to check current element is not same
{
$(this).text('Write something');
}
});
})
Run Code Online (Sandbox Code Playgroud)
或者还有另一种方法吗?
$("div.show").click(function() {
$("div.show").not(this).text('Write something');
})Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="show">Element 1</div>
<div class="show">Element 2</div>
<div class="show">Element 3</div>Run Code Online (Sandbox Code Playgroud)