lawx
lawx

Reputation: 388

jQuery & jQuery UI code not running

I have jquery UI and jQuery linked on my page, and I have the following jQuery UI code currently on the page:

  $(function() {
    $( "#draggable" ).draggable({ containment: "parent"});
    });

I want to have this jquery code run below the code above:

function new() {  
    $("p").append("<strong>Hello</strong>");
}

But for some reason it's not working when both are in the same place and as a newbie to jQuery, I'm not sure what's wrong (both of the codes were mostly copied and pasted from the site). I suspect it's something to do with the function statement.

Upvotes: 0

Views: 66

Answers (1)

new is a reserved keyword in javascript (it's used as syntax to create new objects) so you can't use it as a function name. Try using a different name for your function, for example:

function mynew() {  
    $("p").append("<strong>Hello</strong>");
}

Upvotes: 3

Related Questions