How to remove data-toggle="dropdown" data-hover="dropdown" from this:
<a href="#" data-toggle="dropdown" data-hover="dropdown" >Hello</a>
using jquery?
How to remove data-toggle="dropdown" data-hover="dropdown" from this:
<a href="#" data-toggle="dropdown" data-hover="dropdown" >Hello</a>
using jquery?
This data-toggle="dropdown" and data-hover="dropdown" Where HTML 5 data- Attributes.
Here is the code to remove require data- attribute that you want to remove from multiple data- attribute.
HTML
<div id="me"><a id='me1' title="title" data-toggle="dropdown" data-hover="dropdown" data-Sample="test1" >Hello</a></div>
Before:<br>
<div id="before"></div>
After<br>
<div id="after"></div>
JQ
var data = $("a").data();
var keys = $.map(data , function(value, key) { return key; });
$("#before").text($("#me").html());
for(i = 0; i < keys.length; i++) {
// here you can remove data- attribute that you want to remove from multiple data- attribute
// here you can add 'if' condition for any For data- attribute you want to remove
if (keys[i].indexOf('toggle') != -1 || keys[i].indexOf('hover') != -1) {
$("a").removeAttr("data-" + keys[i]);
}
}
$("#after").text($("#me").html());
Here is the Live Demo
if this help's you Reply me Dude..