Jump to content

Wrap div tags inside a <a> tag?


Nocktis

Recommended Posts

Hello everyone.  I'm using Prestashop 1.6 and I'm trying to take advantage of the fact that HTML 5 now allows block level elements to be wrapped inside an <a> tag.  Specifically I'm looking to wrap a few <div> tags inside an <a> tag.

 

For example:

 

<a href="http://www.google.com"><div>Div content without other links here</div></a>

 

However, the editor is not allowing this.  Can anyone help me out with this?  At first I was trying to use a onclick event on the div container but I realize that's not the best option and the editor strips out onclick tags.  I've already followed the instructions here (http://mypresta.eu/en/art/prestashop-16/extended-rich-text-editor.html) to extend TinyMCE but this still is not working.

 

Any help is greatly appreciated!

Link to comment
Share on other sites

Is it possible to use that right inside the body of the CMS page?  I'm going to have a CMS page with about 8 <div> containers that I need clickable.  I'd hate to have to include a bunch of extra jQuery code in a global file that is only needed on one CMS page.  Thanks for the help.

Link to comment
Share on other sites

Ahh looks like you can.  Perhaps there's a more efficient way to do this but for now this is what's working for me (all inside one CMS page):

 

<div class="divlink1">Content here</div>
<div class="divlink2">Content here</div>
<div class="divlink3">Content here</div>


<script>
$(".divlink1").on('click', function() {
  window.location = "http://www.google.com";
});


$(".divlink2").on('click', function() {
  window.location = "http://www.someotherurl.com";
});


$(".divlink3").on('click', function() {
  window.location = "http://www.thirdurl.com";
});
</script>
Now all I need to do is add some CSS and this will work great.  Thanks again for the help!
Edited by Nocktis (see edit history)
Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...