Forum Moderators: open
<div id="list_1234" data-listid="1234" data-user="ZHJpZnRlcmd1eTMzMzM">
Blah
</div> <p onClick="$('div').data('user', 'ZHJpZnRlcmd1eTMzMzM').hide();">
Hide all from this user
</p> <div id="list_1234" data-listid="1234" class="user-ZHJpZnRlcmd1eTMzMzM">
Blah
</div>
<p onClick="$('div .user-ZHJpZnRlcmd1eTMzMzM').hide();">
Hide all from this user
</p> <p onClick="$('*[data-user=\"ZHJpZnRlcmd1eTMzMzM\"]').hide();"> The first example you gave was selecting all div elements, but not filtering the results. So you end up hiding all div.
Invalid or unexpected token <p onClick="$('div[data-user=\'ZHJpZnRlcmd1eTMzMzM\']').hide();">
<p onClick="$('div[data-user=ZHJpZnRlcmd1eTMzMzM]').hide();"> $('p[data-name]').on('click', function() {
$("div[data-user=" + $(this).data('name') + "]").hide();
});
<p data-name="ZHJpZnRlcmd1eTMzMzM"> The problem is definitely with the double quotes,
<p onClick=" ~OPEN DOUBLE~ $(" ~CLOSE DOUBLE~ div[data-user=' ~OPEN SINGLE~ ZHJpZnRlcmd1eTMzMzM'~CLOSE SINGLE~]"~OPEN DOUBLE~).hide();" ~CLOSE DOUBLE~> I guess a more complicated solution would be to do something like this
From a Perl background, I only use double quotes when I need a string to be interpreted inside the quotes...
advantage to doing it any of these ways instead using a dynamic class name?
advantage to doing it any of these ways instead using a dynamic class name?
<div id="list_1234" data-listid="1234" data-user="ZHJpZnRlcmd1eTMzMzM">
Blah
</div>
[data-user="ZHJpZnRlcmd1eTMzMzM"]
<p onClick="$('[data-user=\'ZHJpZnRlcmd1eTMzMzM\']').hide();">
Hide all from this user
</p>