0
I need to manipulate a div
from the click on another div
.
Basically, one is on top of the other, I want to click the top one and so the bottom one runs the event .toggled()
. But one cannot be inside the other.
HTML
<div id="titulo" class=" toggled " align="left">Histórico</div>
<br>
<div id="divTabela">
<table id="tabelainfo" name="tabelainfo" class=" bordasimples ">
<thead>
<tr id="titulotabela">
<th>Data</th>
</thead>
<tbody>
<tr id="corpotabela">
<td align="center">15/5/2014 </td></tr>
<tr id="corpotabelaalt" align="center">
<td align="center">16/5/2014 10:56:10</td></tr>
<tr id="corpotabela">
<td align="center">16/5/2014 11:00:28</td></tr>
</tbody>
</table>
<br><br></div>
Javascript
$("*").on("click", ".toggled", function(event){
event.preventDefault();
event.stopPropagation();
console.log($(this));
$(this).css({"color":"red","border":"2px solid red"});
$(this).next("div").toggle();
});
What you suggest to me?
Enter the. next() between selector and slideToggle() so your answer will be correct, as well as the new Fiddle where I inserted the correction from your suggestion: http://jsfiddle.net/mayconfsbrito/2kLpu/4/
– mayconfsbrito
I forgot the . next(). Thank you so much for pointing out rs.
– dsantoro