1

Can I dynamically add/append some javascript in script tags to an html template - The reason I need to do it is because the user only clicks on this if the user chooses to provide the education information in the first place. Any thoughts? Sorry if this sounds confused as I am confused.

var id_add_script = "#more_ed" + add_school_count;

var add_script = "$( id_add_script ).one('click', function() {$( id_add_script   ).hide().append(more_ed_degree_list).show('slow');});";

var add_script_withTags = "<script>" + add_script + "</script>";

$("form").after(add_script_withTags);
4

1 回答 1

3

Why not just execute the code?

var id_add_script = "#more_ed" + add_school_count;
$( id_add_script ).one('click', function() {
    $( this ).hide().append(more_ed_degree_list).show('slow');
});
于 2013-04-18T19:23:20.897 回答