小编Ror*_*san的帖子

按照链接使用两个输入和按钮标签包括输入值

如何在不编写额外的 javascript(即 html 输入和按钮标签中的所有代码)的情况下跟踪输入字段中带有值的链接?

假设有一个用于搜索的 Google 站点并且搜索行在输入中,因此当您单击按钮时,https://www.google.com/search?q=例如,链接和输入字段的值将text被替换:

https://www.google.com/search?q=text

<input type="text" id="search" name="search" value="text">
<button onclick="code">Follow a search link with a value in input</button>
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery web

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

如何组合不同div标签中的单选按钮

我把单选按钮放在不同的位置 div

请参阅以下示例

HTML

<div><input type="radio" /></div>
<div><input type="radio" /></div>
<div><input type="radio" /></div>
<div><input type="radio" /></div>
Run Code Online (Sandbox Code Playgroud)

那么我怎样才能使这些中的一个可选?

在这里直播jsfiddle

html css jquery

-1
推荐指数
2
解决办法
3995
查看次数

prop()需要太长时间

我有一个<select>元素显示来自大数据库的值.使用jQuery我需要选择相关的项目.问题是当我有大量的物品需要选择时,大约60,000,这个时间$(options2select).prop('selected',true)可能需要很长时间,大约50秒!

注意:我attr()以前使用过这个方法,但是读到的地方prop()更快,而不是!

我正在寻找一种优化此任务的方法,但我找不到任何方法.任何建议将被认真考虑.

javascript jquery

-1
推荐指数
1
解决办法
54
查看次数

在append()中使用三元表达式

我尝试在 jQuery 中使用三元表达式append()。我已经检查了控制台,没有显示错误。问题是tr不附加到tbody.

$(".invoice table tbody").append("<tr> \
    <td> <span class=''>" + price.toFixed(0) == 0 ? Obs : 1 + "</span></td> \
    <td> <span class=''>" + price.toFixed(2) + "</span> </td> \
    <td> <input type='checkbox' name='removeItem' class='removeItemCheckBox'/></td> \
</tr>");
Run Code Online (Sandbox Code Playgroud)

javascript jquery lambda

-1
推荐指数
1
解决办法
1640
查看次数

使用jQuery的元素长度为0

我正在尝试使用以下代码填充ul

item = []
item.push('<li title ="head"' + 'id="' + innerValue + '">' + innerKey + " : " + innerValue + '</li>');

alert('<li title ="head"' + 'id="' + innerValue + '">' + innerKey +" : " + innerValue + '</li>');
alert($('[title="head"]').length);
Run Code Online (Sandbox Code Playgroud)

第一个警报给了我正确的价值.但第二个警报显示长度为0.

上面的代码有问题吗?

jquery attributes list

-1
推荐指数
1
解决办法
29
查看次数

获取任何点击的 td jquery 的值

我正在尝试获取任何单击的 td 的值,并使用 jquery 或 javascript 在 alert() 窗口中显示它。我在互联网上“谷歌搜索”周围有很多代码,但任何人都可以做到这一点,但无论如何我要在这里发布......

$("table tbody").click(function() {
  alert($(this).find('td.value').text());
});

$(document).ready(function() {
  $('table tbody').find('tr').click(function() {
    alert("row find");
    alert('You clicked row ' + ($(this).index() + 1));
  });
});

$(document).ready(function() {
  $('table tbody').click(function() {
    var i = $(this).index();
    alert('Has clickado sobre el elemento número: ' + i);
  });
});

$("table tbody").live('click', function() {
  if $(this).index() === 1) {
  alert('The third row was clicked'); // Yes the third as it's zero base index
}
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table border="1"> …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

-1
推荐指数
1
解决办法
9029
查看次数

如何使用Javascript禁用所有具有相同Id的重复Texbox?

我有不同数量的具有相同Id的TextBox.我被迫使用相同的Id.I没有使用Class的权限.我只需要启用第一个TextBox并禁用其余的TextBox.

这是我的3个不同TextBox的代码:

<input type="Textbox" id="abc" data-templatefieldid="12" required="required" placeholder="Son">

<input type="Textbox" id="abc" data-templatefieldid="12" required="required" placeholder="Son">

<input type="Textbox" id="abc" data-templatefieldid="12" required="required" placeholder="Son">
Run Code Online (Sandbox Code Playgroud)

我需要像这样的输出,我需要启用第一个并禁用其余的:

<input type="Textbox" id="abc" data-templatefieldid="12" required="required" placeholder="Son">

<input type="Textbox" id="abc" data-templatefieldid="12" disabled="disabled" required="required" placeholder="Son">

<input type="Textbox" id="abc" data-templatefieldid="12" disabled="disabled" required="required" placeholder="Son">
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

-1
推荐指数
1
解决办法
1943
查看次数

循环遍历div中的所有元素,并将所有元素tabindex设置为-1

如何遍历div中的所有元素并将所有元素设置tabindex-1

$('.somediv').each(function() {

});
Run Code Online (Sandbox Code Playgroud)

javascript jquery

-1
推荐指数
1
解决办法
432
查看次数

将 SVG 元素转换为字符串

在网页中,我已将 SVG 文件加载到 div 中,如下所示:

<svg id="svg" width="500px" height="500px">
    <g id="1">
        <rect id="0" x="50" y="25" width="50px" height="50px" style="fill:blue;"/>
        <rect id="2" x="110" y="125" width="50px" height="50px" style="fill:blue;"/>
    </g>
    <g id="2">
        <circle id="2" cx="150" cy="50" r="40"  stroke-width="4"  />
        <polygon id="3" points="200,10 250,190 160,210" style="stroke-width:1" />
    </g>
</svg>
Run Code Online (Sandbox Code Playgroud)

然后通过一些循环,我将每个节点放入一个数组中,看起来像这样:

array[<g id="1"></g>,<rect id="0" x="50" y="25" width="50px" height="50px" style="fill:blue;"/>, <rect id="2" x="110" y="125" width="50px" height="50px" style="fill:blue;"/>, <g id="2"><circle id="2" cx="150" cy="50" r="40"  stroke-width="4"/>,<polygon id="3" points="200,10 250,190 160,210" style="stroke-width:1" />]
Run Code Online (Sandbox Code Playgroud)

这里的问题是将它们存储为对象,我希望将其存储为字符串,我已经在任何对象上尝试过诸如 JSON.stringify 之类的东西,但到目前为止还没有运气。我正在使用 javascript 和 jQuery

javascript jquery svg

-1
推荐指数
1
解决办法
6545
查看次数

如何获得标签的htmlFor

我正在尝试for使用jQuery 获取label元素的属性.到目前为止,我的所有尝试都产生了不正确的反应.

        console.log($('label'.htmlFor)); //e.fn.init.....
        console.log($('label').htmlFor)); //undefined
        console.log($('label.htmlFor')); //[prevObject.....]..
        console.log($('label[for]')); 
        console.log($('label')); //same as directly above
        console.log($('label[for].htmlFor')); //[prevObject.....]..
        console.log($('label[for]').htmlFor)); //undefined
Run Code Online (Sandbox Code Playgroud)

我知道htmlFor定义为我可以在chromes web检查器中看到它.我究竟做错了什么?

jquery

-1
推荐指数
1
解决办法
1174
查看次数

标签 统计

jquery ×10

javascript ×7

html ×3

css ×2

attributes ×1

lambda ×1

list ×1

svg ×1

web ×1