जोड़ें मैं यह जांचने की कोशिश कर रहा हूं कि पहले से ही सरणी में कोई मान है या नहीं। यदि मान सरणी में मौजूद नहीं है, तो यह मान सरणी में जोड़ा जाना चाहिए, यदि मान पहले से मौजूद है, तो इसे हटाया जाना चाहिए।jQuery: जांच करें कि मान सरणी में है, यदि ऐसा है, तो हटाएं, यदि नहीं, तो
var selectArr = [];
$('.media-search').mouseenter(function(){
var $this = $(this);
$this.toggleClass('highlight');
}).mouseleave(function(){
var $this = $(this);
$this.toggleClass('highlight');
}).on('click',function(){
var dataid = $(this).data('id');
if(selectArry){ // need to somehow check if value (dataid) exists.
selectArr.push(dataid); // adds the data into the array
}else{
// somehow remove the dataid value if exists in array already
}
});