Reputation: 6489
let's say I have a mark-up like this:
<script>
var doSomething = function () {
var container = $('.container');
var list = $('#result-list');
list.find('.result').attr('id', 'x');
container.append(list.html());
};
</script>
<script type="text/html" id="result-list">
<div class="result"></div>
</script>
<a href="#" onclick="doSomething();">DO</a>
<div class="container">
</div>
I can't change div
id attribute which is placed inside html-script
. I don't know what or where is the problem. Any advice will be helpful.
Upvotes: 2
Views: 365
Reputation: 2865
Are you looking for this.
var doSomething = function () {
var container = $('.container');
var list = $('#result-list');
container.append(list.html());
container.find('.result').attr('id','x');
};
Upvotes: 2
Reputation: 646
<script>
var doSomething = function () {
var container = $('.container');
var list = $('#result-list');
var $result = $(list.html());
$result.attr('id','x');
container.append($result);
};
</script>
Upvotes: 1