It may be trivial, but I have following code that is dynamically adding some href attributes to an <a> element, with important variables that are passed to php generated page in a pop-up window.
jQuery(document).ready(function(){
var url = jQuery("a.special-links").attr("href");
var data = "?iframe=true&width=800&height=350&format=popup";
jQuery("a.special-links").attr("href", url + data);
});
When inspected the page with Firebug, the <a> element got the url href properties right, but link does not work. When I inspect the code looking at source code, I see that href data part was in fact not added!
Is this runtime problem or something else ? Thanks for clues…
You do no see the changes when you view source of the page because when you
view sourceyou are viewing the actual HTML document that was downloaded by the browser when you loaded the visited the URL. This can NEVER be changed by javascript.When you write javascript you change something called the
Document Object Modelaka theDOM. This is an in memory data structure built by the browser as a result of parsing the HTML document. This is what firebug enables you to inspect.