Reputation: 3107
So, in one area of my program, I am setting a custom html property to true:
$(document).on('click', '.profile-player-show', function(event) {
$('.player-profile-pop').attr('inLineup', true);
}
Then, when that info is retrieved in another later function, I'm noticing that the boolean has a type of String now and it's not really a shock, I just want to know what the rules are...? Here is an example of my code in the latter:
var inLineup = $('.player-profile-pop').attr('inLineup');
console.log("In Lineup:" + inLineup + " Type of data:" + typeof inLineup);
var btnText = (inLineup === 'true') ? "Remove From Lineup" : "Add To Lineup";
The console logs:
In Lineup:true Type of data:string
So, is a Boolean automatically converted to a string when using the jQuery .attr() function to set a variable such as true or false?
Upvotes: 2
Views: 468