Question

In: Computer Science

Write a jQuery click event handler for all tags within elements. In the handler, output the...

Write a jQuery click event handler for all tags within

elements. In the handler, output the src attribute of the image to the console.

Solutions

Expert Solution

Jquery Click event handler sample code:

1. 
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>click demo</title>
  <style>
  p {
    color: red;
    margin: 5px;
    cursor: pointer;
  }
  p:hover {
    background: yellow;
  }
  </style>
  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
 
<p>First Paragraph</p>
<p>Second Paragraph</p>
<p>Yet one more Paragraph</p>
 
<script>
$( "p" ).click(function() {
  $( this ).slideUp();
});
</script>
 
</body>
</html>


2. 
$( "#target" ).click(function() {
  alert( "Handler for .click() called." );
});


3. 
<div id="target">
  Click here
</div>
<div id="other">
  Trigger the handler
</div>

4. 
$("p").dblclick(function(){
  $(this).hide();
});

5.
$("#p1").mouseenter(function(){
  alert("You entered p1!");
});

6.
$("#p1").mouseleave(function(){
  alert("You entered p1!");
});

7.
$("#p1").hover(function(){
  alert("You entered p1!");
},
function(){
  alert("Bye! You now leave p1!");
});

Related Solutions

Topic: HTML Styling Elements - CSS3 Write some HTML code that includes three Semantic HTML tags....
Topic: HTML Styling Elements - CSS3 Write some HTML code that includes three Semantic HTML tags. Describe the semantic meaning of each one you choose.
Write a PHP Program to display all the $_SERVER elements
Write a PHP Program to display all the $_SERVER elements
C++ question. I want to write all output to the file "output.txt", but it will write...
C++ question. I want to write all output to the file "output.txt", but it will write just first character. Can you fix it? #include #include #include #include #include using namespace std; using std::cin; using std::cout; using std::string; // remove dashes convert letters to upper case string normalize(const string &isbn) { string ch; for (char i : isbn) { if (i == '-') { continue; // if "-" then skip it }    if (isalpha(i)) { i = toupper(i); // Check...
C++ question. I want to write all output to the file "output.txt", but it will write...
C++ question. I want to write all output to the file "output.txt", but it will write just first character. Can you fix it? #include #include #include #include #include using namespace std; using std::cin; using std::cout; using std::string; // remove dashes convert letters to upper case string normalize(const string &isbn) { string ch; for (char i : isbn) { if (i == '-') { continue; // if "-" then skip it }    if (isalpha(i)) { i = toupper(i); // Check...
Write a MIPS assembly program that calculates the sum of all the elements in the following...
Write a MIPS assembly program that calculates the sum of all the elements in the following array: int array[10]={12,21,3,40,15,6,17,8,29,10}
Write an algorithm that doubles ALL the prime values of a linked lists, and then output...
Write an algorithm that doubles ALL the prime values of a linked lists, and then output the whole new list.
write a recursive method that returns the product of all elements in java linked list
write a recursive method that returns the product of all elements in java linked list
ONLY IN C LANGUAGE Write a C program to print all the unique elements of an...
ONLY IN C LANGUAGE Write a C program to print all the unique elements of an array. Print all unique elements of an array Enter the number of elements to be stored in the array: 4 Input 4 elements in the arrangement: element [0]: 3 element [1]: 2 element [2]: 2 element [3]: 5 Expected output: The only items found in the array are: 3 5
Recursion java: 1. Write a recursive algorithm to add all the elements of an array of...
Recursion java: 1. Write a recursive algorithm to add all the elements of an array of n elements 2. Write a recursive algorithm to get the minimum element of an array of n elements 3. Write a recursive algorithm to add the corresponding elements of two arrays (A and B) of n elements. Store the results in a third array C .4. Write a recursive algorithm to get the maximum element of a binary tree 5. Write a recursive algorithm...
1) Write an XPath expression to find all elements (anywhere in the input document) having a...
1) Write an XPath expression to find all elements (anywhere in the input document) having a born element anywhere inside them. 2) What does the XPath expression /html/body//div[1] return? 3) Write an XPath expression to find all elements (anywhere in the input document) that do not have an id attribute.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT