English 中文(简体)
利用 j子列出检查箱组的所有检查值。 IE FF和NookOT的工程
原标题:Using jQuery to list all checked values of a checkbox group. Works in FF and Chrome NOT in IE

这部法典在FF和Kings公司中进行了一些工作,以换取一个经过限制的加价清单:

$( #lifesteps-group-0 :checked ).each(function() {
  if (allSteps.length === 0) {
      allSteps = $(this).val();
}
else {
    allSteps = allSteps +  ,  + $(this).val();
     }
});

Basically the lifesteps-group-0 div has all of the checkboxes in them. Like I said above it works beautifully in FF and Chrome, but only works for the first checkbox in IE.

这里还有检查箱组的形式:

<div id="lifesteps-group-0">                        
    <div>
        <input type="checkbox" class="checkbox" name="lifesteps-0" id="lifesteps-0-22" value="22">
        <label for="ls-22" class="checkboxgroup">Began preparation as a missionary canidate</label>
    </div>                      
    <div>
    <input type="checkbox" class="checkbox" name="lifesteps-0" id="lifesteps-0-23" value="23">
    <label for="ls-23" class="checkboxgroup">Began a small group, helped in a church plant</label>
     </div>
</div>

oh GU GURUS?

感谢

方 法

最佳回答

You can use .map() for this a bit cleaner and faster, like this:

var allSteps = $( #lifesteps-group-0 :checked ).map(function() {
                 return this.value;
               }).get().join( ,  );

如果allSteps是一个隐含的全球(我看不见在你的代码中宣布),那么,它将在独立实体(如你再次看到)中 throw弃一些棘手的问题,在宣布这一问题时最安全。

问题回答

Your checkboxes should have different IDs but same name.

你的遴选人不应以该身份证为基础。

尝试启动<代码>allSteps 变量

它按照规定在E8中工作;在IE8与他人一起工作。

var allSteps=  ;




相关问题
Image rendered with wrong colors in IE8

I have a gradient image as a PNG (no transparency) in a web-page. By taking a screenshot of Chrome showing the page and cropping the image from the page, I see the exact same colors are drawn as the ...

Determine Mobile Internet Explorer version

I need to determine the version of Mobile Internet Explorer on a Windows Mobile 6.1 device. So that I can report the same user-agent string as is being used by Mobile Internet Explorer. The user-...

CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

Internet Explorer only part loading JavaScript/CSS

I m having trouble with my local development environment where IE (6 through to 8) is only part loading JavaScript/CSS files. It throws random errors at random places in jquery.min.js every time I ...

IE doesn t run Javascript when you click back button

I ve built a shop with tons of JS running. One of the pieces of the cart, is a zip code field which is required to calculate shipping cost. This works fine going through the cart. Now clicking ...

热门标签