Monday, 11 April 2016

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

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...