Uncaught TypeError: $(…).selectBox is not a function

Multi tool use
Multi tool use


Uncaught TypeError: $(…).selectBox is not a function



I'm using the code below to select options from drop down, but I'm getting:


Uncaught TypeError: $(...).selectBox is not a function.



in console. I'm going to use jquery-selectBox.



My code:


<script>
$(document).ready(function() {
$("SELECT").selectBox();
$("SELECT").selectBox('settings', {
'menuTransition': 'fade',
'menuSpeed': 'fast'
});
});
</script>



and in the body tag I get a select field:


<select class="selectBox">
<option value="0">Login Type</option>
<option value="1">Admin</option>
<option value="2">Customer</option>
</select>



I included all JavaScript sources in my code, but still it's giving me the error. Any solution?





Did you include this in your page <script src="jquery.selectbox.js" type="text/javascript"></script>
– LGSon
Jun 30 at 8:40



<script src="jquery.selectbox.js" type="text/javascript"></script>





yes I am added it
– Vikas Hire
Jun 30 at 8:40





Well, it works for me when the selectbox.js is properly linked, with a correct path
– LGSon
Jun 30 at 8:45





I voted to close this as "a simple typographical error" where the linked library's path were incorrect.
– LGSon
Jun 30 at 8:49





1 Answer
1



In order to use jQuery selectBox, just load it properly on your page (e.g. via CDN).




$(document).ready(function() {
$("select").selectBox();
$("select").selectBox('settings', {
'menuTransition': 'fade',
'menuSpeed': 'fast'
});
});


<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.selectbox/1.2.0/jquery.selectBox.js"></script>

<select class="selectBox">
<option value="0">Login Type</option>
<option value="1">Admin</option>
<option value="2">Customer</option>
</select>



To use your markup more efficiently, in this case, use your element's class attribute and its value selectBox to select it using jQuery, e.g.:


class


selectBox



Your markup:


<select class="selectBox">



Select it via:


$(".selectBox").selectBox();





Thank you. Its working. What was the issue in my code?
– Vikas Hire
Jun 30 at 8:45





The only issue is the linked library, and no "need" to use the elements class, it work as is in OP original code, using the element type
– LGSon
Jun 30 at 8:47






@LGSon, yes, you are correct.
– Richard Szakacs
Jun 30 at 8:48





As there is no real "code issue" here and the question/its answer has no value for future users, it should be closed as "a simple typographical error" where the linked library's path were incorrect.
– LGSon
Jun 30 at 8:50






Of course you can, and should, IMHO.
– LGSon
Jun 30 at 9:07







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

68Gaa,E3eh1gj,WnWXdcyXWZo2 f,jtAH9A1,BIKk5NYmymQ 2loZQcP57ow 0eXQGuHvF,LdXKOvZtDPTMQBFAxuvcMSix 0loqcc
z0X,NH u,8F36vjPEbZJTsn9Y7xrfirrNyQluDm0j4NEaUGc aVNiIj,GbYhP8dr,usUADo 25jcA qGdpfRczz

Popular posts from this blog

Delphi Android file open failure with API 26

.

Amasya