English 中文(简体)
阵列最后囚室中的不想要物体
原标题:An unwanted object in the last cell of an array

采用以下规范的XML阵列:

$(this).find("cp_group").each(function() {
    $("select#comp_1").append( <optgroup label="  + $(this).attr( label ) +  "><option>  + $(this).find("cmp").map(function() {
        return $(this).text();
    }).get().join("</option><option>") + $(this).append( </option></optgroup> ));
});​

在每一选项组的最后一种选择中,一获得不想要的[目标]:

<select name="comp_1" id="comp_1">
<optgroup label="Combat">
<option>Arme</option>
<option>Arts martiaux</option>
<option>Esquive</option>
<option>Feinte</option>
<option>Parade</option>
<option>Lutte[object Object]</option>

I dont understand from where this [object Object] come from and I didn t achieve to not get it or to remove it. Thanks for you help.

最佳回答

它来自<代码>+美元(原文)。 您只希望<代码>+ </option.... part,而没有这种分类。

问题回答

页: 1 当你操纵酒吧时,你不再处理markup(大体),你再处理objects(多功能元素)。

应确定:

$(this).find("cp_group").each(function() {
    // Get this entry
    var $this = $(this);

    // Create the optgroup
    var optgroup = $( <optgroup label="  + $this.attr( label ) +  "> );

    // Fill it in
    $this.find("cmp").each(function() {
        $("<option>").text($(this).text()).appendTo(optgroup);
    });

    // Append it to the select
    $("select#comp_1").append(optgroup);
});​




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

热门标签