I’ve designed a block of <div></div> to use with javascript and jQuery. I would use this div block on several pages. I found it’s hassled to given new id to every one of them and code identical javascript/jQuery for them all.
Can I use the same id and javascript codes for every page?
Actually, some time ago for a test sake I tried to use the same ID in DIV’s in a page. It worked. But I cannot be sure it will work on other browsers and other computers, too. So, to be safe just use distinct ID’s. I made a large hierarchic system of ID’s and CLASSes for our Portfolio section:
[font=verdana]It depends what you mean by “it worked”. If you have, let’s say, two lots of <div id=“section1”>…</div>
then this will probably work:
#section1 {border:1px grey solid;}
but it’s very unlikely that either of these two will reliably work:
var editsection = document.getElementById('section1')
<a href="#section1">Jump to section 1</a>
As the original question was about using the ID as a hook for Javascript, you need to be careful about what you’ve tested multiple IDs for (and yes, I know you did put a disclaimer about it not being guaranteed to work on different browsers and computers).[/font]