添加/删除行css
我为我的网站添加了动态下拉搜索菜单。如果您转到我提供的链接,您会注意到左侧有两个链接,用于表选项中的javascript添加/删除行,在我将添加/删除行css,css,Css,我为我的网站添加了动态下拉搜索菜单。如果您转到我提供的链接,您会注意到左侧有两个链接,用于表选项中的javascript添加/删除行,在我将class=“chzn select”(动态搜索菜单)添加到下拉菜单之前,这些链接正常工作。发生的情况是,当添加类时,由于某种原因,它不再添加新行 在左侧的菜单上,您可以单击查看操作中的NoCSS表,以及有问题的CSS表,其中包含class=“chzn select”。我认为问题在于,这个菜单的css是动态的,取决于菜单处于哪个状态,但无法找出问题出在哪里。
class=“chzn select”
(动态搜索菜单)添加到下拉菜单之前,这些链接正常工作。发生的情况是,当添加类时,由于某种原因,它不再添加新行
在左侧的菜单上,您可以单击查看操作中的NoCSS表,以及有问题的CSS表,其中包含class=“chzn select”
。我认为问题在于,这个菜单的css是动态的,取决于菜单处于哪个状态,但无法找出问题出在哪里。谢谢你的帮助
测试链接:用户:test1通过:test1
添加/删除使用的脚本:jsfiddle.net/frtrc
谢谢
我会在这里粘贴css代码,但网站一直说它包含代码,无论我如何格式化,都不允许我发布..:\ 问题来自一个插件,该插件创建了一个带有搜索栏的样式下拉列表(用于选择国家) 它显示用于筛选国家/地区列表的输入字段。问题是此输入字段没有
id
-属性,因此执行以下代码时,它没有任何要拆分的id,数组将为空
$tr.find("input,select").attr("name", function()
{
// break the field name and it's number into two parts
var parts = this.id.match(/(\D+)(\d+)$/);
// create a unique name for the new field by incrementing
// the number for the previous field by 1
return parts[1] + ++parts[2];
// repeat for id attributes
}).attr("id", function(){
var parts = this.id.match(/(\D+)(\d+)$/);
return parts[1] + ++parts[2];
});
解决方案是首先确保有一个要拆分的id。更多信息请点击此处:
此外,您还可以使用
clickMe()
-函数捕获onclick
-事件没有任何作用,并生成错误。当您使用select.jquery.min.js和choose.css在select选项后生成动态新div时,问题就会出现,因此javascript无法工作
$tr.find(“输入,选择”).attr(“名称”,函数(),因为只有两个标记添加输入和选择
我建议添加javascript行
$(document).ready(function($)
{
$('#sif_roba1').next('div').attr("id","sif_roba1");//Chane Code
$('#sif_roba1').next('div').attr("name","sif_roba1");
// trigger event when button is clicked
$("button.add").click(function()
{
// add new row to table using addTableRow function
addTableRow($("table"));
// prevent button redirecting to new page
return false;
});
// function to add a new row to a table by cloning the last row and
// incrementing the name and id values by 1 to make them unique
function addTableRow(table)
{
// clone the last row in the table
var $tr = $(table).find("tbody tr:last").clone();
// get the name attribute for the input and select fields
$tr.find("input,select,div").attr("name", function()
{
// break the field name and it's number into two parts
var parts = this.id.match(/(\D+)(\d+)$/);
// create a unique name for the new field by incrementing
// the number for the previous field by 1
return parts[1] + ++parts[2];
// repeat for id attributes
}).attr("id", function(){
var parts = this.id.match(/(\D+)(\d+)$/);
return parts[1] + ++parts[2];
});
// append the new row to the table
$(table).find("tbody tr:last").after($tr);
$tr.hide().fadeIn('slow');
// row count
rowCount = 0;
$("#table tr td:first-child").text(function() {
return ++rowCount;
});
// remove rows
$(".remove_button").on("click", function() {
$(this).parents("tr").fadeOut('slow', function () {
$(this).remove();
rowCount = 0;
$("#table tr td:first-child").text(function() {
return ++rowCount;
});
});
});
};
});
好的,在该页面上更改其他内容…你应该在这里发布你的代码,以防其他链接有一天会消失。我会的,但确实有很多,它只会阻塞帖子,这就是为什么我提供了实时网站来查看它的运行情况。谢谢你指出了这个问题,但我不知道从哪里开始。你能给我一些提示吗一些指针指出了具体需要做什么,实际上需要更改哪些部分?如果您确实想重新构造或更改您的解决方案,一个简单的建议是确保文本框有一个id。尝试将其放入就绪函数:$(“.chzn search”).find(“input”).attr(“id”,“searchbox1”);我更新了上面的链接,但仍然是一样的..还有其他建议吗?