I try to have access to the row i clicked to add or remove a class, but it seems like i misinterpreted the value of this
. Isn't it supose to be the DOM where the event go called (in this case, the <li>
)? Here is my code:
JAVASCRIPT
$(document).on('click', '.ToDownload', function()
{
if($(this).className.lastIndexOf("isSelected") != -1)
{
$(this).addClass("isSelected");
$(this).css('border', '2px solid #000099')
}
else
{
$(this).removeClass("isSelected");
$(this).css('border', 'none')
}
});
HTML
<li id="addedDownloadFileRow" class="fitting ToDownload">
<a href="#">
<div class="ui-grid-a">
<div class="ui-block-a">test1</div>
<div class="ui-block-b">test2</div>
</div>
</a>
</li>
In fact, i thought i could use the property className
to find if my row is already selected, but it seems like this
isnt the DOM of the <li>
tag. Any information or a way to see what this
really is would be appreciated.
P.S. The class "fitting" is only used for some css purpose.