English 中文(简体)
Javascript - use of inner xenophobia 守则审查中的“id”方法
原标题:Javascript - usage of innerHTML & id methods in code review

所有人,

这里是我正在撰写的一篇发言稿。

WHAT IT DOES: When the blue button is pressed, a div should appear on top of the box containing the 5000 number.

我面临的问题是使用内装的超文本和安放;向有活力的零件分配补助。 我没有在火焰中发现任何错误,因此我不敢确定什么/什么是错的。

问题方针:

eCreditTransactions[i].id = ("trans" + i);

eCreditTransactions[i].innerHTML =  <div class="cCreditContainer"><span class="cCreditsNo">-50</span>&nbsp;<img class="cCurrency" src="" alt="" /></div><span class="cCloseMsg">Click box to close.</span><div class="dots"></div><div class="dots"></div><div class="dots"></div> ;

这里是一部完整的法典:

var eCreditSystem = document.getElementById("creditSystem");
var i = 0;
var eCreditTransactions = new Array(6);                 // 6 instances created which will be recycled

function createCreditTransaction ()                 // func called when a transaction occurs, at the mo, attached to onclick()
{
    if (i < 6)
    {
        $(eCreditTransactions[i]).remove();
        eCreditTransactions[i] = undefined;                 // to delete the existing data in the index of array
        addingElements (i);                 // calling function
    } else
    if (i > 5 || eCreditTransactions[i] != undefined)
    {
        i = 0;
        $(eCreditTransactions[i]).remove();
        eCreditTransactions[i] = undefined;
        console.log(eCreditTransactions[i]);
        addingElements (i);
    }
}

function addingElements (arrayIndex)                    // func called from within the  createCreditTransaction()  func
{
    console.log(eCreditTransactions[i]);
    eCreditTransactions[i] = $(document.createElement( div )).addClass("cCreditTransaction").appendTo(eCreditSystem);

// the problem area

    eCreditTransactions[i].id = ("trans" + i);
    eCreditTransactions[i].innerHTML =  <div class="cCreditContainer"><span class="cCreditsNo">-50</span>&nbsp;<img class="cCurrency" src="" alt="" /></div><span class="cCloseMsg">Click box to close.</span><div class="dots"></div><div class="dots"></div><div class="dots"></div> ;

    console.log(eCreditTransactions[i]);
    return i++;
}

rel=“nofollow”>Jsfiddle

最佳回答
问题回答

暂无回答




相关问题
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.