English 中文(简体)
选择down
原标题:Set Select Dropdown with jQuery

这个问题已经多次提出,但这不是重复的问题。 我正在通过包括选择、投入等在内的一系列要素进行搜索。 它将类别名称与物体参数相匹配,如果该名称与元件值相符。

for(var i in obj) {
    if(obj.hasOwnProperty(i)) {
        $(editClone).find( .  +i).val(obj[i]);
    }
}

它对投入内容做了细微的工作,但选修内容将排除所有选择,简单地确定实际要素的数值。

这是我发言之前的选定发言:

<select class="type">
    <option value="Home">Home</option>
    <option value="Work">Work</option>
    <option value="Mobile">Mobile</option>
    <option value="Other">Other</option>
</select>

在我管理该法典之后(在火力中为核实而检查):

<select class="type">Mobile</select>

为什么这样做? 我认为,“阀()”应当为选定的对应选择设定一个对应选择。 标的和选择的对口是匹配的,但它没有做应该做的事情。 我在这里做了什么错误?

www.un.org/Depts/DGACM/index_spanish.htm 在我面前,我曾试图在超文本的错误位置上掩饰nes,并在java字母上打坏衣。 完全无关的错误。 下面的回答是正确的,因为我不理解我所面对的问题,因此,我的情况只是没有做。

最佳回答
<select class="type">Mobile</select>

无效。 选择需要<代码>option 内部的标签


本文是您的法典工作版本:

rel=“nofollow”>DEMO

<select class="type">
    <option value="0">0</option>
    <option value="A">A</option>
</select>

原文:

$(function() {

    var obj = { type: "A" };

    var editClone = $(document);

    for(var i in obj) {
        if(obj.hasOwnProperty(i)) {
            $(editClone).find( .  + i).val(obj[i]);
        }
    }
});
问题回答

暂无回答




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

热门标签