Injecting Elements into with jQuery
When working with content management systems (CMSs), editing the HTML source of the
element is often restricted. However, there are methods to add elements to the dynamically using jQuery or JavaScript.Problem:
You want to add a element to the
above the<code class="html"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /></code>
Solution:
Using jQuery, you can select the
element and append a link as follows:<code class="javascript">$('head').append('<link />');</code>
This will dynamically inject the element into the
of the page. Similarly, you can add other elements, such as or