Before and After help whats wrong with my code


#1


$(document).ready(function(){
  $('#one').after(<p>'Hello'/p>);
});

SyntaxError: Unexpected token '<'

Replace this line with your code.


#2

$(document).ready(function(){
$('#one').after('Hello'/p>)
});
});
isn't working either


#3

I'm not sure what parameter to pass to .after, but you are passing a string, 'hello' and also passing /p>, which seems to be an incomplete closing paragraph tag. Please add description and I can help you further.


#4

Text nodes do not get quotes in HTML, but jQuery selectors are quoted when then are plain text strings.

$('#one').after('<p>Hello</p>');

This will create a paragraph element in the DOM which may be selected in the statement that follows.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.