English 中文(简体)
javascript subsequently into a function astring including Whitespace is truncated at first Whitespace?
原标题:javascript passing into a function a string containing whitespace is truncated at first whitespace?

一些人可以向我解释,为什么你能够把含有白天空间的扼杀作为 parameters印功能的参数?

我在此阐述这一问题的法典,只是对联系的 h,你认为,只有“mario”被显示为标题,而不是“mario and luigi”。

 var href= mario and luigi , subject=$( div ).data( subject ), 
 size=$( div ).data( reviewid ), 
      src=$( div ).data( itemid ), className= mini ;

      function formatLink(href, subject, src, size, className){            
                if(size== mini )
                size= height:25px; width:25px; ;
                else if(size== medium )
                size= height:40px; width:40px; ;
                else if(size== large )
                size= height:125px; width:125px; ;
                else if(size== xlarge )
                size= height:180px; width:260px; ;                
            return  <a class="pjax" href= +href+  title= +subject+ ><span class= +className+ ><span class="image-wrap" style="position:relative; display:inline-block; background:url( +src+ ) no-repeat center center; +size+ " ><img style="opacity:0;"></span></span><span title= +subject+ > +subject+ </span></a> ;
        }
var link=formatLink(href, subject, src, size, className);
$( div ).html(link);
​
最佳回答

。 您需要援引属性,否则标识无效。

作为一种奖金,这里使用的是仿照format功能,使类似情况更容易:

format = function(str, params) {
    return str.replace(/{(w+)}/g, function($0, $1) { return params[$1] });
}

使用:

html = format(
     <a class="pjax" href="{href}" title="{subject}"><span class="{className}"... etc ,
    {
        href: "some_link",
        subject: "mario and luigi",
        className: "foobar"
    }
)
问题回答
return  <a class="pjax" href= +href+  title= +subject+ ><span 

页: 1 添加引文(标题也相同):

return  <a class="pjax" href=" +href+ " title=" +subject+ "><span 




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签