简体   繁体   English

如何用javascript onclick包装我的链接?

[英]How to wrap up my link with javascript onclick?

I have this link 我有这个连结

<div class="new-div" ><a href="<?php the_permalink(); ?>"><?php the_title(); ?>

In this case user has to press on the title to get the link and I want also to wrap up div class with the link. 在这种情况下,用户必须按标题才能获得链接,我还想用该链接包装div类。 Tried several variants. 尝试了几种变体。 I think there should be a solution with javascript onclick function, but do not know actually how to wrap it up. 我认为应该使用javascript onclick函数解决方案,但实际上不知道如何包装它。 Thank you for your help. 谢谢您的帮助。

<div class="new-div" onclick="location.href='<?php the_permalink(); ?>'"><a href="<?php the_permalink(); ?>"><?php the_title(); ?>  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM