Tom Knowlton
asked on
invoke a function call
<script type="text/javascript">
$(document).ready(function ()
{
$('#f1').css("border", "3px solid blue");
});
</script>
instead of changing the css border style, I want to call a javascript function. How do I do this?
$(document).ready(function
{
$('#f1').css("border", "3px solid blue");
});
</script>
instead of changing the css border style, I want to call a javascript function. How do I do this?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
$('#f1').Yourfunction();
I don't think that syntax is valid, but it expresses my intent.
In plain English it would say "Select all elements with id of f1 and then call Yourfunction( ) on each one (assuming you find at least ONE match)
I don't think that syntax is valid, but it expresses my intent.
In plain English it would say "Select all elements with id of f1 and then call Yourfunction( ) on each one (assuming you find at least ONE match)
ASKER
I guess this works:
$(document).ready(function ()
{
if ($('#f1').length > 0)
{
somefunction();
}
});
function somefunction() {alert("hi");}
The alert message appears when I hit the page.
Is there a better / cleaner way to do this?
$(document).ready(function
{
if ($('#f1').length > 0)
{
somefunction();
}
});
function somefunction() {alert("hi");}
The alert message appears when I hit the page.
Is there a better / cleaner way to do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thx
Just as an aside, if you have more than one f1, you should use a class not id. There should only be one unique id per page.
Glad I could help,
Cheers.
Glad I could help,
Cheers.
ASKER
Thank you!
btw, are you familiar with jQuery plugin "qtip" ??
http://craigsworks.com/projects/qtip/docs/reference/#content
I am trying to add an image to the callout
btw, are you familiar with jQuery plugin "qtip" ??
http://craigsworks.com/projects/qtip/docs/reference/#content
I am trying to add an image to the callout
I don' t know it off the top of my head. But you should post a new question and I can look into it...
ASKER