Reputation: 346317
...what does it mean? I have almost no experience with jQuery, and need to work with some existing code.
All the tutorials talk about is using $() with pseudo-CSS selectors, but what would be the meaning of something like this:
$(function makeFooWriteTooltip() {
if($("div[name='txttooltip']").length>0){
$("div[name='txttooltip']").each(
function(){
Upvotes: 4
Views: 113
Reputation: 50832
jQuery( callback ) ( which equals to $(callback) )
Upvotes: 3
Reputation: 630429
It's a shortcut for:
$(document).ready(function makeFooWriteTooltip() {
Though, the function need not have a name here. Passing a calback to $()
runs the function on the document.ready
event, just a bit shorter, these are equivalent:
$(document).ready(function() {
//code
});
$(function() {
//code
});
Also, given your exact example, there's no need to check the .length
, if it's there it runs, if not the .each()
doesn't do anything (no error), so this would suffice:
$(function () {
$("div[name='txttooltip']").each(function(){
Upvotes: 9