Sunday, July 1, 2018

javascript - hide elements with name using jquery





I am using backbone and



I have following code in template



    >
>


and in render function i have following code




  render: function() {
$(this.el).html(this.template(this.model));
var selectedElem='[name='+self.model.leave_request_id+']';
console.log(selectedElem);
console.log($(selectedElem));
//$("a[name='"self.model.leave_request_id+"']" )
$(selectedElem).hide();


return this.el;

}


console.log(selectedElem) prints [name=3257]



and console.log($(selectedElem)) prints



[a#approveLeave.al_ynbtn.apv_app, a#rejectLeave.al_ynbtn.can_app, prevObject: m.fn.init[1], context: document, selector: "[name=3257]", jquery: "1.11.1", constructor: function…]
0: a#approveLeave.al_ynbtn.apv_app
1: a#rejectLeave.al_ynbtn.can_app

context: document
length: 2
prevObject: m.fn.init[1]
selector: "[name=3257]"
proto: Object[0]



i want to hide elements with name=3257? how to do that?


Answer



I think you're missing quotes around your names:







No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...