Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
196
rated 0 times [  198] [ 2]  / answers: 1 / hits: 18129  / 15 Years ago, wed, september 2, 2009, 12:00:00
$('#selector').click(function() {
// here I would like to load a javascript file
// let's say /js/script-on-click-event.js
});


Is that somehow possible? I'm not sure but I remember reading about a function that does this in JQuery documentation but I cannot find it here, maybe it's been deprecated or I saw it elsewhere?



Basically what I want is to load a script on a click event.


More From » jquery

 Answers
40

Something like
jQuery.getScript



$(#selector).click(function(){
$.getScript(http://dev.jquery.com/view/trunk/plugins/color/jquery.color.js);
});

[#98771] Sunday, August 30, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
breap

Total Points: 606
Total Questions: 96
Total Answers: 108

Location: Djibouti
Member since Sun, Feb 27, 2022
2 Years ago
breap questions
Thu, Jun 24, 21, 00:00, 3 Years ago
Wed, Mar 18, 20, 00:00, 4 Years ago
Mon, Oct 7, 19, 00:00, 5 Years ago
;