我确信这很简单,我似乎无法理解它。我试图在点击时添加属性值。
所以有这个按钮
<input domain_id="9" class="home_send_but" value="send" type="button">
点击后
$('.home_send_but').click(function(){
domain_id = $(this).attr('domain_id');
$('#send_but').attr('domain_id').val(domain_id);
});
它应该将domain_id为9添加到:
<input domain_id="" id="send_but" type="button" value="Send Now">
但是,send_but的domain_id属性仍为null。
那么如何为属性添加值?
是的,我知道我应该使用数据属性。
答案 0 :(得分:4)
答案 1 :(得分:0)
https://api.jquery.com/attr/#attr2
您的代码应为var pages = ["home", "about", "contact"];
$locationProvider.html5Mode(true);
$routeProvider.otherwise({ redirectTo: "/" });
for(var i = 0, len = pages.length; i < len; i++){
$routeProvider.when("/" + pages[i], angularAMD.route({
//assign templateUrl, controller, controllerURl etc. here
});
}