Javascript jquery: Difference between revisions
From wikinotes
(One intermediate revision by the same user not shown) | |||
Line 24: | Line 24: | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
function | function hospitalAndAddr() { | ||
var | var hospital = $(this).children("h3")[0].innerText; | ||
var addr = $(this).children("p")[0].innerText; | var addr = $(this).children("p")[0].innerText; | ||
return `${ | return `${hospital}\n${addr}`; | ||
} | } | ||
var | var hospitals = $("article.hospitals").map(hospitalAndAddr); | ||
console.log( | for (const h of hospitals) { | ||
console.log(h); | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Example --> | </blockquote><!-- Example --> |
Latest revision as of 19:53, 4 February 2023
Abstracts HTML DOM, CSS, events, AJAX.
Documentation
official docs https://api.jquery.com/ home https://jquery.com/
Tutorials
w3schools tut https://www.w3schools.com/jquery/default.asp
Example
function hospitalAndAddr() { var hospital = $(this).children("h3")[0].innerText; var addr = $(this).children("p")[0].innerText; return `${hospital}\n${addr}`; } var hospitals = $("article.hospitals").map(hospitalAndAddr); for (const h of hospitals) { console.log(h); }
Notes
jquery datatypes jquery selectors jquery events jquery elements