Reputation: 84
I want to remove class "ndfHFb-c4YZDc-aSZUA-Wrql6b" from div (to hide some toolbar)See image
<div class="ndfHFb-c4YZDc-aSZUA-Wrql6b" role="toolbar" style="width: 226px; right: 12px; opacity: 1;"><div class="ndfHFb-c4YZDc-aSZUA-Wrql6b-AeOLfc-b0t70b"><div class="ndfHFb-c4YZDc-nJjxad-nK2kY......
i try to do it simple with
$('.ndfHFb-c4YZDc-aSZUA-Wrql6b').remove();
$('div.ndfHFb-c4YZDc-aSZUA-Wrql6b').remove();
but it dont work. Thanks in advance
Upvotes: 1
Views: 892
Reputation: 5640
So as I've understood the problem comme from the fact that it is included in a <iframe>
In this case you can try something like :
$('iframe').contents().find('[role="toolbar"]).removeClass('ndfHFb-c4YZDc-Wrql6b')
Upvotes: 0
Reputation: 2803
Personally I would set an id to the div and then target the id in jquery... Then remove the Class.
if($("div[role='toolbar']").length){
$("div[role='toolbar']").removeClass('ndfHFb-c4YZDc-aSZUA-Wrql6b');
}
Link: http://jsfiddle.net/g0srar72/2/
Upvotes: 0
Reputation: 11693
To remove class use removeClass
EDITED
if($('div[role="toolbar"]').hasClass("ndfHFb-c4YZDc-aSZUA-Wrql6b")){
$('div[role="toolbar"]').removeClass("ndfHFb-c4YZDc-aSZUA-Wrql6b");
}
Refer Link
Explanation : Grab Div with role toolbar and check if it has class XYZ if yes remove the class from that div.
Upvotes: 0
Reputation: 418
You were really close.
$('div.ndfHFb-c4YZDc-aSZUA-Wrql6b').removeClass('ndfHFb-c4YZDc-aSZUA-Wrql6b');
is the correct solution. Make sure not to include the class' .
when using removeClass
.
I'd encourage you to rename the class to something more human readable.
Also, as Donte suggested, it would be best if you gave the div
an id to allow you to target it consistently.
Upvotes: 1