Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
44
rated 0 times [  45] [ 1]  / answers: 1 / hits: 27972  / 13 Years ago, fri, december 16, 2011, 12:00:00
<script type=text/javascript src=jscripts/jquery.js></script>

<script type=text/javascript>
$(document).ready(function(){
alert(funciton);
$(function(){
$.fn.gotof(){
alert(I am calling form jquery);
}
});
});
</script>


<input type=button onclick=dofunc();>

<script type=text/javascript>
function dofunc(){
gotof();
}
</script>


how do i call gotof() that is present in jquery
and below is the code written over jsfiddle


More From » jquery

 Answers
12

There are a few errors in your code. Fixed it should look like this:



$.fn.gotof = function() { // has to be defined as a function, does not need to be inside a nested document ready function
alert(I am calling form jquery);
};

$(document).ready(function() {
alert(function is ready to use now);
});

function dofunc() {
$.fn.gotof(); // can call it using $.fn.gotof(), but it should really be called properly via a selector $('div').gotof();
}


http://jsfiddle.net/pSJL4/8/


[#88526] Wednesday, December 14, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brynnleslis

Total Points: 425
Total Questions: 100
Total Answers: 115

Location: Wallis and Futuna
Member since Tue, Mar 30, 2021
3 Years ago
;