i am using a script from bing. Well, when i run it, it assigns an attribute "lang" to all of the elements and changing my own styling. The script is online so i can't edit it. What i can do is remove that attribute from all the elements using jquery so no styling change would occur. This is what i have tried so far after searching through.
$('body').children("*").removeAttr('lang');
$('body').find("*").removeAttr("lang");
They are not working. Any suggestion?
i am using a script from bing. Well, when i run it, it assigns an attribute "lang" to all of the elements and changing my own styling. The script is online so i can't edit it. What i can do is remove that attribute from all the elements using jquery so no styling change would occur. This is what i have tried so far after searching through.
$('body').children("*").removeAttr('lang');
$('body').find("*").removeAttr("lang");
They are not working. Any suggestion?
Share Improve this question asked Dec 28, 2013 at 6:34 Awais UmarAwais Umar 2,0774 gold badges28 silver badges47 bronze badges 5- it has to be executed after the bing script is executed – Arun P Johny Commented Dec 28, 2013 at 6:36
- @Prannav Ram I tried it alrady but it is also not working. – Awais Umar Commented Dec 28, 2013 at 6:37
- @ArunPJohny yes i am executing it after the script. But it is not working. – Awais Umar Commented Dec 28, 2013 at 6:38
-
as a debugging step try
setTimeout(function(){$('body').find("*").removeAttr("lang")}, 5000)
– Arun P Johny Commented Dec 28, 2013 at 6:45 - 1 Post a link to the Bing JavaScript file. – Blender Commented Dec 28, 2013 at 6:47
4 Answers
Reset to default 6You can use Has Attribute Selector [name]
and then use removeAttr()
Selects elements that have the specified attribute, with any value.
$('[lang]').removeAttr('lang');
console.log($('span').prop('outerHTML'))
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span lang='en'>1</span>
Give this a try.
$('*').removeAttr('lang');
$($("body [lang]").removeAttr("lang"))
Add this after the script:
setTimeout(function(){
$('body').find('*').removeAttr("lang");
}, 0);