I have a div containing li’s and a div containing a table. When there is a hover on a li I want the “system” to take the “refSortie” attribute and hide the table rows for which the “refDate” attribute equals the “refSortie” attribute. My code is not working. Hope someone can help. Thank you in advance for your replies. Cheers. Marc.
My HTML :
<div id="contentWrapper">
<div id="contentOne" class="content">
<ul>
<li refSortie="mmm">MMMMM</li>
<li refSortie="sss">SSSSS</li>
<li refSortie="mmm">MMMMM</li>
<li refSortie="ppp">PPPPP</li>
</ul>
</div>
<div id="contentTwo" class="content">
<table>
<tr refDate="mmm"><td>MMMMM</td><td>hdqjkhs</td><td>hdqjkhs</td></tr>
<tr refDate="mmm"><td>MMMMM</td><td>hdqjkhs</td><td>hdqjkhs</td></tr>
<tr refDate="ppp"><td>PPPPP</td><td>hdqjkhs</td><td>hdqjkhs</td></tr>
<tr refDate="sss"><td>SSSSS</td><td>hdqjkhs</td><td>hdqjkhs</td></tr>
</table>
</div>
<div id="contentThree" class="content"></div>
<div id="contentFour" class="content"></div>
</div>
My JS :
$('#contentOne li').hover(function(){
var refSortie=$(this).attr('refSortie');
if(!$('#contentOne').hasClass('freezed')){
$('#contentTwo table tr[refDate=refSortie]').css("display":"none");}
}).mouseout(function(){
if(!$('#contentOne').hasClass('freezed')){
$('#contentTwo table tr[refDate=refSortie]').css("display":"inline");}
});
You have a multitude of things going on here. Fixed js code:
http://jsfiddle.net/brentmn/cRJdz/
The errors were:
refDate=refSortie//needs to be variablecss("display":"inline")// if you want to set css this way, you must use an obj e.g.css({"display": "inline"})