
Skip to main content
How to make entire Div clickable in javascript
There are lots of method available to make a div clickable in Javascript. But here we have to get the link of anchor tag which is the inner element of div tag and redirect the user to the link using window.location.
-
Make a div clickable using inner anchor tag with javascript
<!-- HTML --> <div class="myBox"> blah blah blah. <a href="http://google.com">link</a> </div>
<!-- javascript --> <script> $(".myBox").click(function() { window.location = $(this).find("a").attr("href"); return false; }); </script>
You can make the entire div clickable using the value of href attribute of anchor tag which is child element of div.
Bootstrap
Cmd
CodeIgniter
Css
Drupal
Git
Html
Javascript
Jquery
Laravel
Nodejs
Php
Python
Sql
Typescript
Wordpress
Random Code Snippet Queries: Javascript
- How to set href value of anchor tag in javascript
- Copy one array to another in javascript
- Check if value exists in array javascript
- How to display an image in Javascript onclick
- How to display for slash as a string in javascript HTML
- Get multiplication in javascript using array input
- How to add key/value pair to existing form data
- JavaScript test() Method
- How to push string in an array in Javascript
- How to preview a word document in HTML using javascript
- Execute function with condition in javascript
- How to add a property to object with condition in javascript
- Cropper js with multiple images
- Javascript to print Fibonacci series upto 15 Observations
- How to echo array in Javascript
- Trim the leading and trailing comma from string in Javascript
- How to pass array as arguments to function in javascript
- Uncaught TypeError: Assignment to constant variable
- Hide div on click outside of element in javascript/jQuery
- Javascript set timeout function with example code
- How to fixed bootstrap navbar at top on scroll
- Remove hostname from URL in javascript
- How to check caps lock is on in javascript
- How to preview video before uploading in javascript
- How to get query string value in javascript