document.getElementById(""").className = """";无法在 IE 中工作

发布于 2024-12-15 22:27:48 字数 910 浏览 6 评论 0 原文

我在这里创建了一个业务生成器:http://minespress.net/web_apps/business-cards/

我使用 document.getElementById("...").className = "..."; 创建了一个预览窗格,它会在单击(缩略图的)时切换背景图像,并根据的设计名片。这在 FF、Chrome 和 Safari 中完美运行。当我在 IE 中尝试时,onClick 没有任何反应。

我还应该提到,我的拇指是单选按钮,需要根据是否选中它们来更改表单操作。再次在除 IE 之外的其他浏览器中运行良好。是否有一些 IE 错误或者我只是做了一些完全错误的事情?

这是我的代码的示例:

<input
    style="display:none"
    checked="checked"
    name="group1"
    id="2"
    value='http://minespress.net/web_apps/business-cards/img/twinkle-blue.jpg'
    type="radio"
    onclick="document.getElementById('card').className ='Default'; document.getElementById('compname').className ='', document.getElementById('slogan').className ='', document.getElementById('leftinfo').className ='', document.getElementById('rightinfo').className =''" />

I created a business generator here: http://minespress.net/web_apps/business-cards/

I created a preview pane using document.getElementById("…").className = "…"; which switches the background image onClick (of the thumbnail) and also moves around the text divs depending on the design of the business card. This works flawlessly in FF, Chrome and Safari. When I tried it in IE nothing happened onClick.

I should also mention that my thumbs are radio buttons that need to change the form action based whether or not they are checked. Once again works fine in other browsers besides IE. Is there some IE bug or am I just doing something completely wrong?

Here is an example of my code:

<input
    style="display:none"
    checked="checked"
    name="group1"
    id="2"
    value='http://minespress.net/web_apps/business-cards/img/twinkle-blue.jpg'
    type="radio"
    onclick="document.getElementById('card').className ='Default'; document.getElementById('compname').className ='', document.getElementById('slogan').className ='', document.getElementById('leftinfo').className ='', document.getElementById('rightinfo').className =''" />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

戏剧牡丹亭 2024-12-22 22:27:48

IE 8 不支持图像作为输入字段的标签。这就是我的单选按钮不起作用的原因。现在我只需要弄清楚如何解决这个问题。

IE 8 does not support images as labels for input fields. This is why my radio buttons do not work. Now I just need to figure out how to work around this.

渔村楼浪 2024-12-22 22:27:48

使用 setAttribute 代替:

var ele = document.getElementById('card')
ele.setAttribute('class', 'Default');

Use setAttribute instead:

var ele = document.getElementById('card')
ele.setAttribute('class', 'Default');
明月夜 2024-12-22 22:27:48

您是否尝试将 , 更改为 ; ? IE 可能比其他浏览器更挑剔...

更改

"document.getElementById('card').className ='Default'; document.getElementById('compname').className ='', document.getElementById('口号').className ='', document.getElementById('leftinfo').className ='', document.getElementById('rightinfo').className =''"

"document.getElementById('card').className ='Default'; document.getElementById('compname').className =''; .className =''; document.getElementById('leftinfo').className =''; document.getElementById('rightinfo').className =''"

看看是否如此解决你的问题。

Did you try changing the ,s to ;s? IE might be pickier than the other browsers...

Change

"document.getElementById('card').className ='Default'; document.getElementById('compname').className ='', document.getElementById('slogan').className ='', document.getElementById('leftinfo').className ='', document.getElementById('rightinfo').className =''"

to

"document.getElementById('card').className ='Default'; document.getElementById('compname').className =''; document.getElementById('slogan').className =''; document.getElementById('leftinfo').className =''; document.getElementById('rightinfo').className =''"

and see if that solves your problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文