overflowstack9 overflowstack9 - 4 months ago 7
Javascript Question

how to remove this click action javascript from the combobox

The below is my code but i just want to implement simple combobox without the click. I mean i want to remove it in html and also in jquery. If i remove

<a href="javascript:void(0)">Click</a>


then which jquery code should i remove in the above code



$(function(){
var CB = $("select").kendoComboBox();

$("a").click(function(){

});
});

<html>
<head>
<script class="jsbin" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<link href="http://cdn.kendostatic.com/2012.1.515/styles/kendo.common.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2012.1.515/styles/kendo.default.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2012.1.515/styles/kendo.dataviz.min.css" rel="stylesheet" />
<script src="http://cdn.kendostatic.com/2012.1.515/js/kendo.all.min.js"></script>
</head>

<body>
<select>
<option>One</option>
<option>Two</option>
<option>Three</option>
</select>
<a href="javascript:void(0)">Click</a>
</body>
</html>




Answer

If you want to remove the click action, just do :

$('a').off('click');

.on() add listener
.click() is equal to .on('click')
.off() remove listener

In your above code, if you don't want the click listener just remove the click part :

$("a").click(function(){

});

So your jquery function will look like this :

$(function(){
    var CB = $("select").kendoComboBox();
});