Is it possible to expand existing html tag?
For example i want add type of <link>
tag and make some action on this type
<link rel="stylesheet" type="new-type" href="theme.css">
and when we have link with new type make some action automatically?
Is it possible to expand existing html tag?
For example i want add type of <link>
tag and make some action on this type
<link rel="stylesheet" type="new-type" href="theme.css">
and when we have link with new type make some action automatically?
Yes, you can. The best to do this is to use the data-
attributes. Those are skipped by any validator so safe to use for your own purpose:
<link id="someId" rel="stylesheet" type="new-type" href="theme.css" data-special="true">
If you use jQuery, you can even get it out easy:
var x = $("#someId").data("special");
You can use insertAdjacentHTML
. In the example below the new element will be inserted after the element defined by `getElementById("link"):
var element = document.getElementById("link");
var newElement = '<link rel="stylesheet" type="new-type" href="theme.css">'
element.insertAdjacentHTML( 'afterend', newElement )
See this link for the full documentation: https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML
yes you can. you have to do a simple modification to your code like below-
<link rel="stylesheet" data-type="new-type" href="theme.css">