Jump to content

Automatically assigning <strong> element


kurt.santo

Recommended Posts

With regard to post "Great cross-browser working dynamic sidebar" I would like to automatically assign the <strong> element instead of hard-coding it into each page. How would you do this? I will do the nav bar with HTML only (no database yet). I will change this later on. For now, I do not want to over-complicate matters for my learning curve;-)KurtBTW: Again with reference to my other post, the mentioned book is great (although some is really above my head right now). I found that other code samples on the internet sometimes do not work properly with my browsers, which adds to my confusion. The book seems to cater for all browser problems and has a lot of great code samples in it.

Link to comment
Share on other sites

Do you mean you want to remove <strong> from the html code and dynamically place it around "Products"?
In a perfect world I would not hardcode the strong element into any page. For the third level in the menu structure (the levels above can be hard-coded as there won't be too many) I would like to have links for all entries in the nav bar, but the current page's link should be replaced with a strong element (if possible???)... They actually refer all to the same php page (called products). I pass the nav bar entry in the form products.php?id=36 (still, obviously the user has to know onto which item he clicked). Can this be done with JavaScript at all?Kurt
Link to comment
Share on other sites

I, personally, would use styles to make the text bold:

var link = document.getElementById("mylink");link.style.fontWeight = "bold";

But, you could also do something like this:

var link = document.getElementById("mylink");var html = "<strong>" + link.innerHTML + "</strong>";link.innerHTML = html;

Link to comment
Share on other sites

I, personally, would use styles to make the text bold:
var link = document.getElementById("mylink");link.style.fontWeight = "bold";

But, you could also do something like this:

var link = document.getElementById("mylink");var html = "<strong>" + link.innerHTML + "</strong>";link.innerHTML = html;

That makes sense. But how do you assign id "mylink" automatically to current page? There lies my problem :) Kurt
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...