Jump to content

make <div> behave like <a> tag?


adredz

Recommended Posts

i have a div that has a onclick attribute. the problem is i can't right-click(to open to a new tab) on it and it won't display the target link on the browser's status bar. i know i can insert a <a> tag, but it requires a text for the link and it would make things complicated for me since i already have the background image of my div marked with text. any help?

Link to comment
https://forums.phpfreaks.com/topic/187927-make-behave-like-tag/
Share on other sites

It's bad practice to use javascript for opening links, as users without javascript turned on will not be able to use the link.

 

Change the div to an <a> tag, and apply your background to that. It will fix all your problems, including the ones you didn't realize you have.

Link to comment
https://forums.phpfreaks.com/topic/187927-make-behave-like-tag/#findComment-992281
Share on other sites

  • 3 weeks later...

i have a div that has a onclick attribute. the problem is i can't right-click(to open to a new tab) on it and it won't display the target link on the browser's status bar. i know i can insert a <a> tag, but it requires a text for the link and it would make things complicated for me since i already have the background image of my div marked with text. any help?

 

You can wrap the div in an ancher tag, this would allow it to be clicked, and rightclicked accordingly (as long as it's in the div itself and not in interelements)

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.