简体   繁体   English

为什么相同的代码在不同的页面上显示不同?

[英]Why does the same code display differently on different pages?

Hi have a small entry form that is jquery driven. 嗨,有一个小的条目形式是由jquery驱动的。 It works fine on 90% of the pages, but on two pages, the Submit button is out of alignment. 在90%的页面上都可以正常工作,但是在两页上,“提交”按钮没有对齐。 I have checked the html and the jquery on working and non-working pages and can't see the difference. 我已经检查了工作页面和非工作页面上的html和jQuery,看不到区别。 I would appreciate another set of eyes taking a look to see what is causing the Submit button to be so far off. 我希望能有另一双眼睛看一下是什么原因导致“提交”按钮相距太远。

Here is a working page (scroll to the bottom to the newsletter signup form): view page 这是一个工作页(滚动到通讯注册表单的底部): 查看页

Here is page where it doesn't work correctly: view page 这是无法正常工作的页面查看页面

Here is the html for the form: 这是表单的html:

<div id="news-signup">
      <div id="entry">
          <input type="text" id="your-email" name="your-email" value="YOUR EMAIL ADDRESS" onfocus="if (this.value=='YOUR EMAIL ADDRESS') this.value='';" />
          <input type="submit"  value="::Submit Query::" id="red-submit" />
      </div>
    </div>

Here is the jquery that does the swap out: 这是执行换出的jQuery:

$(document).ready(function() {
    var emailInput = $("#your-email");

    emailInput.focus(function() {
        //  THREE = !
        if(this.value === "YOUR EMAIL ADDRESS") {
            this.value = "";
        }
    });

    emailInput.blur(function() {
        if(this.value === "") {
            this.value = "YOUR EMAIL ADDRESS";
        }
    });

    $("#red-submit").click(function() {
        $.ajax({
            type: 'POST',
            url: 'news.php',
            data: {
                'your-email': emailInput.val()
            },
            success: function() {
                var image = $('<img />').attr({src:'_images/register-thanks.png', width:332, height:35, alt:"Success"});
                $('#news-signup input').hide();
                $('#news-signup').append(image);                
            }
        });
    });
});

Here is the CSS for positioning: 这是用于定位的CSS:

#news-signup #entry,
#news-signup form                   { 
        width:335px; 
        height:35px;  
        position: absolute;
        top: 52px;
        left: 590px;
        }


#news-signup input#your-email       { 
        width: 195px;
        height: 20px;
        position: relative; 
        top: 5px; 
        left: 0; 
        -moz-border-radius: 5px; 
        -webkit-border-radius: 5px;
        border: 1px solid #cbcbcb; 
        font: 14px "Trebuchet MS", Helvetica, sans-serif;
        color: #cbcbcb; 
        }   
#news-signup img                    { position: absolute; top: 50px; left: 600px; }                                                                 

input#red-submit                    {
            width: 90px;
            height: 30px;
            border-style: none;
            text-indent: -9999px; 
            position: relative;
        top: -20px;
        left: 250px; 
        cursor: pointer;
        font-size: 0;
        line-height: 0;
        background-color: transparent;
        background-image: url(../_images/btn_submit-red.png); 
        }

Thanks for the help! 谢谢您的帮助!

I compared what CSS styles are applied to each element using firebug, and there is no differences between the pages. 我比较了使用Firebug将哪些CSS样式应用于每个元素,并且页面之间没有差异。 Then I tried to elliminate errors in the rest of the code by removing the content piece by piece, and it doesn't make any difference either. 然后,我试图通过逐段删除内容来消除代码其余部分中的错误,这也没有任何区别。 With that elliminated there is only the code in the form itself left. 省略的代码只剩下表单本身中的代码。

There is some error in the HTML code itself in the form, perhaps an invisible control character. HTML代码本身的形式有一些错误,也许是看不见的控制字符。 When I take the code for the form from the page where it works and paste it in the page of the non-working form, it works. 当我从其工作页面上获取表单代码并将其粘贴到非工作表单的页面中时,它就可以工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM