Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery How to Continue Javascript to New Line?

This is lingering question I have and while it may seem like a noob - that's ok as I am one.

How do I continue a new line in jQuery selectors ? I understand that javascript new lines are simply

(\) single backslash

Such as

var someString = 'abc\
defghi';
alert(someString);

Yet using jQuery - this doesn't work when I am listing long selectors ? i.e.

$('#id, .class, .class1, .class2, .class3, .class4, .class5, \
   .class6, .class7').click(function() {
      //some stuff
});

Can anyone shed some light how to resolve this ?

like image 710
Tom Avatar asked Sep 20 '11 14:09

Tom


People also ask

How do I continue the next line in JavaScript?

Adding a backslash at the end of each line tells the JavaScript engine that the string will continue to the next line, thus avoiding the automatic semicolon insertion annoyance.

How do you add a new line in jQuery?

You have to use <br> to have line breaks. You can replace line breaks to <br> just for display.


1 Answers

$('#id, .class, .class1, .class2, .class3, .class4, .class5, ' + 
  '.class6, .class7').click(function() {
      //some stuff
});

http://jsfiddle.net/X6QjK/

like image 116
AlienWebguy Avatar answered Oct 08 '22 15:10

AlienWebguy