?
Solved

Unexpected identifier in this line of code

Posted on 2013-06-10
2
Medium Priority
?
406 Views
Last Modified: 2013-06-10
I'm new to JQuery and trying to get this example going

https://github.com/tuupola/jquery_lazyload#readme

I downloaded the jquery library, added class ="lazy". But now, I added this line of code
$("body").append("<script>$("img.lazy").lazyload();</script>"); 

Open in new window


to a .js code that's already in the project but it throws an error : unexpected identifier

not sure why.
init: function() {
				// register initializations here
				
				// quick view dialog div
				jQuery("<div/>").attr("id", "QuickViewDialog").html(" ").appendTo(document.body);
				
				// bonus product dialog div
				jQuery("<div/>").attr("id", "BonusProductDialog").html(" ").appendTo(document.body);
				
				
				$("body").append("<script>$("img.lazy").lazyload();</script>"); 
	
				// micicart object initialization
				this.minicart.init();
				
				// execute unobtrusive js code
				this.execUjs();

Open in new window

0
Comment
Question by:Camillia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 2000 total points
ID: 39235609
Hi,
this is because of a syntax error. The second double quotes will close the string, and then the rest will be the unexpected identifier.
Try this
 $("body").append('<script>$("img.lazy").lazyload();</script>');
0
 
LVL 7

Author Comment

by:Camillia
ID: 39235624
let me try. thanks for your help.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question