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 ?
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.
You have to use <br> to have line breaks. You can replace line breaks to <br> just for display.
$('#id, .class, .class1, .class2, .class3, .class4, .class5, ' +
'.class6, .class7').click(function() {
//some stuff
});
http://jsfiddle.net/X6QjK/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With