开发者

javascript format error

开发者 https://www.devze.com 2023-03-14 15:01 出处:网络
var liHtml = \"<div class=\'slide\'><a href=\'\"+itemLink+\"\' target=\'_blank\' border=\'0\'><img width=\'420\' heigh开发者_高级运维t=\'220\'src=\'\" + imageLink +\"\'/></a>\
 var liHtml = "<div class='slide'><a href='"+itemLink+"' target='_blank' border='0'><img width='420' heigh开发者_高级运维t='220'  src='" + imageLink +"'/></a>" + "<div class="caption" style="bottom:'0'"><p>" + title + "</p></div></div>";

firebug gives me this error

missing ; before statement
[Break On This Error] var liHtml = "<div class='slide'><...'"><p>" + title + "</p></div></div>"; 

what am i missing. The above code should look like below

<div class="slide">
                        <a href="photos/jliba/4665625073/" title="145.365 - Happy Bokeh Thursday" target="_blank"><img src="img/slide-1.jpg" width="570" height="270" alt="Slide 1"></a>
                        <div class="caption" style="bottom:0">
                            <p>Happy Bokeh Thursday!</p>
                        </div>
                    </div>


Replace

"<div class="caption" style="bottom:'0'"><p>" in your concatenation

with

"<div class=\"caption\" style=\"bottom:'0'\"><p>" 

i.e:

var liHtml = "<div class='slide'><a href='"+itemLink+"' target='_blank' border='0'><img width='420' height='220'  src='" + imageLink +"'/></a>" + "<div class=\"caption\" style=\"bottom:'0'\"><p>" + title + "</p></div></div>"; 


Quote mismatch in the string at the point <div class="caption" style="bottom:'0'"><p>. Escaping or using a single quote instead will fix it.


You need to escape your double quotes. Example:

Replace:

 .. + "<div class="caption" style="bottom:'0'"><p>" + ..

With:

..  + "<div class=\"caption\" style=\"bottom:'0'\"><p>" + ..
0

精彩评论

暂无评论...
验证码 换一张
取 消