相关疑难解决方法(0)

我应该使用'name'或'id'制作HTML Anchor吗?

当想要用" http://example.com/#foo"方法引用网页的某些部分时,应该使用

<h1><a name="foo"/>Foo Title</h1>
Run Code Online (Sandbox Code Playgroud)

要么

<h1 id="foo">Foo Title</h1>
Run Code Online (Sandbox Code Playgroud)

他们都工作,但他们是平等的,还是他们有语义差异?

html html5 hyperlink fragment-identifier

762
推荐指数
9
解决办法
60万
查看次数

HTML中id和name属性的区别

idname属性有什么区别?它们似乎都与提供标识符的目的相同.

我想知道(特别是关于HTML表单)是否有必要或鼓励使用两者都是出于任何原因.

html attributes

670
推荐指数
13
解决办法
37万
查看次数

JavaScript表单验证:理解函数调用

我是JavaScript的新手,试图在表单验证上找到自己的方式.我一直在阅读书籍和在线教程,我在网上发现了以下代码,在我看来,这是非常优雅和可维护的.不幸的是,我在JavaScript方面的技能还不足以理解一切.我在这里请求您帮助理解定义的不同功能.

我还想在一个事件(onSubmit事件)上调用InstantValidation函数,在一个独立的.js文件中调用它(基于事件监听器),所以你能帮我调用一下这个函数吗?

这是代码:

<html>

<body>

    <form id="myform" action="#" method="get">
        <fieldset>

            <legend><strong>Add your comment</strong></legend>

            <p>
                <label for="author">Name <abbr title="Required">*</abbr></label>
                <input name="author" id="author" value="" 
                    required="required" aria-required="true" 
                    pattern="^([- \w\d\u00c0-\u024f]+)$"
                    title="Your name (no special characters, diacritics are okay)"
                    type="text" spellcheck="false" size="20" />
            </p>

            <p>
                <label for="email">Email <abbr title="Required">*</abbr></label>
                <input name="email" id="email" value=""
                    required="required" aria-required="true" 
                    pattern="^(([-\w\d]+)(\.[-\w\d]+)*@([-\w\d]+)(\.[-\w\d]+)*(\.([a-zA-Z]{2,5}|[\d]{1,3})){1,2})$"
                    title="Your email address"
                    type="email" spellcheck="false" size="30" />
            </p>

            <p>
                <label for="website">Website</label>
                <input name="website" id="website" value=""
                    pattern="^(http[s]?:\/\/)?([-\w\d]+)(\.[-\w\d]+)*(\.([a-zA-Z]{2,5}|[\d]{1,3})){1,2}(\/([-~%\.\(\)\w\d]*\/*)*(#[-\w\d]+)?)?$"
                    title="Your website address"
                    type="url" spellcheck="false" size="30" />
            </p>

            <p>
                <label for="text">Comment <abbr …
Run Code Online (Sandbox Code Playgroud)

javascript forms validation function handler

5
推荐指数
1
解决办法
587
查看次数

在javascript中这是一个有效的构造吗?:document.name.name.value?

这是表格:

<form name=fname ...
   <input name=iname value="" ...
Run Code Online (Sandbox Code Playgroud)

这个javascript函数获取输入的值:

var val = document.fname.iname.value;
Run Code Online (Sandbox Code Playgroud)

这是合法的吗?我以为你必须这样做getElementsByName.它有效,只是我从未见过有人这样做过.这是恰好恰好工作的那件事之一吗?现在呢?

html javascript dom

3
推荐指数
1
解决办法
246
查看次数

was the name attribute really needed in html?

If the purpose of the name attribute in HTML forms only to reference the element such as input, why couldn't we have simply used id or class attributes? Was there some not so obvious reasoning behind creating the name attribute.

.....html
 Name: <input type="text" name="fullname"><br>
.....
Run Code Online (Sandbox Code Playgroud)

html javascript php

3
推荐指数
1
解决办法
81
查看次数

如何获取表单ID属性位于

我有以下表格:

<form id="formId">
    <!-- some tags -->
    <div>
        <!-- some other divs or something else -->
            <input type="radio" onclick="handler(this) />
    </div>
</form>
Run Code Online (Sandbox Code Playgroud)

函数处理程序的位置如下:

var handler = function(elem){
    init();
    var clicked = //here should be form id
    //other staff
};
Run Code Online (Sandbox Code Playgroud)

如何获取随附表格的ID?假设网页上只有一个表单.

我正在寻找pure-js以及jQuery解决方案.

html javascript jquery

0
推荐指数
1
解决办法
96
查看次数