Вы только смотрите на атрибут Series
в этом подзапросе :
where (
from thread in el.Elements("ThreadDensity")
where
(string)thread.Attribute("Series") == "UNF"
select thread).Any() &&
((string)el.Element("Size") == "#1")
, который просто проверяет, есть ли какой-либо элемент ThreadDensity
внутри [ 115] имеет правильную серию.
Код, в котором вы фактически создаете UTSBolt
, просто получает первый элемент ThreadDensity
:
select new UTSBolt(
(string)el.Element("Size"),
(double)el.Element("MajorDiameter"),
(double)el.Element("ThreadDensity")
);
Я подозреваю, что вы хотите что-то вроде:
[ 112]I just wrote a quick plugin to run a test using your same snippet and it works fine
$.fn.test = function() {
return this.each(function(){
var new_id = 5;
$(this).attr('id', this.id + '_' + new_id);
$(this).attr('name', this.name + '_' + new_id);
$(this).attr('value', 'test');
});
};
$(document).ready(function() {
$('#field_id').test()
});
<body>
<div id="container">
<input type="text" name="field_name" id="field_id" value="meh" />
</div>
</body>
So I can only presume something else is going on in your code. Can you provide some more details?
Did you try
$(this).val('test');
instead of
$(this).attr('value', 'test');
val()
is generally easier, since the attribute you need to change may be different on different DOM elements.
What happens when you set all of the attributes in one attr()
command like so
$(this).attr({
id : this.id + '_' + new_id,
name: this.name + '_' + new_id,
value: 'test'
});
РЕДАКТИРОВАТЬ : исходя из вашего комментария и предполагая, что этот
является клонированным элементом.
$(this).clone()
.attr( 'id', this.id + '_' + new_id )
.attr( 'name', this.name + '_' + new_id )
.val( 'test' )
.appendTo('#someElement');
Полный пример
<script type="text/javascript">
var new_id = 0;
$(document).ready( function() {
$('#container > input[type=button]').click( function() {
var oldinp = $('input#inp')[0];
var newinp = $(oldinp).clone()
.attr('id',oldinp.id + new_id )
.attr('name',oldinp.name + new_id )
.val('test')
.appendTo($('#container'));
$('#container').append('<br>');
new_id++;
});
});
</script>
<div id="container">
<input type="button" value="Clone" /><br/>
<input id="inp" name="inp" type="text" value="hmmm" /><br/>
</div>