Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm having some difficulty with looping through an array and matching it with a string, I have a search box with an autosuggest, when the user types the suggested string appears.
So the idea is to alert when the matches the variable, here is what I have so far, any help would be great.
var DomainCentral = "DomainCentral";
var DomainGuard = "DomainGuard";
$(function() {
var availableTags = [
DomainCentral,
DomainGuard
];
$( "input#tags" ).autocomplete({
source: availableTags
});
for (var i in availableTags){
if (availableTags == DomainCentral) {
alert('hello');
}
}
});
Looks like you need to listen to an event, and do this check when that event happens. This looks like the right event, tho i haven't tried it: http://api.jqueryui.com/autocomplete/#event-response You'll need to read the input, i.e. $('input#tags').val(), and check that value against your array inside the event listener.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 months ago.
Improve this question
Consider this simple attempt to find a value in an object:
var config = {
product1: {
ids: ['master']
},
product2: {
ids: ['ps1', 'ps2']
}
};
var id = 'ps2';
var slotID = 'master';
var categorySlotIds = config[slotID].ids;
categorySlotIds.find(id);
I get: TypeError: Cannot find function find in object product1, product2
If I do typeof(categorySlotIDs) the result is object.
The manual for find says: The find() method returns the first element in the provided array
What gives?
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am getting error on this. i don't know what happen here.
enter code here
$(".addCategory").on('click',function(){
var value= $(".getvalue").val();
var x = $("input[name="+value+'[]'"]")
$(x).each(function(key,val){
if($(val).val().length<=0)
{
alert ("Please fill all the fileds");
}
});
});
You have problem with quotes
var x = $("input[name='" + value + "[]']")
Problem was with your quotes:
replace with following code
$(".addCategory").on('click',function(){
var value= $(".getvalue").val();
var x = $("input[name='"+value+"[]']") // add proper quotes
$(x).each(function(key,val){
if($(val).val().length<=0)
{
alert ("Please fill all the fileds");
}
});
});
See How it should wrap up
var x = $("input[name='"+value+"[]']")
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
This is happening on an angular application I'm building. If a user enters 80 into an HTML input, it always seems to get this comparison wrong.
var x = '80';
var y = 150.9800;
/* Returns incorrect answer */
if (parceFloat(x) < y) {
return true;
} else {
return false;
}
You need to use ParseFloat() not parceFloat() ...
parceFloat is not an existing function.
parceFloat() is not a function, the function is parseFloat()
A simple typo is all the error there is.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I'm writing a simple jquery code to animation an element on my page:
curent
$('#tgs-nav-icon').on('click', function() {
var $nav = (".canvas-menu-content");
var bounceInRight = "bounceInRight animated";
if(! $nav.hasClass(bounceInRight) ) {
$nav.addClass(bounceInRight);
}
else {
$nav.removeClass(bounceInRight);
}
});
Uncaught TypeError: nav.hasclass is not a function
I tried testing this to see where I went wrong and this code comes back false as it should:
var help = $( ".canvas-menu-content" );
console.log(help.hasClass("foo"));
I can't figure out why the if statement is throwing me the error.
I've tried doing some research, but none of the previous questions seem to answer my issue.
You're assigning $nav to the string ".canvas-menu-content" here:
var $nav = (".canvas-menu-content"); // $nav is now '.canvas-menu-content'
Assign it to a jQuery object instead:
var $nav = $(".canvas-menu-content"); // $nav is now a jQuery object containing all
// elements with class canvas-menu-content
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Hi I want to find text url in my editor and convert them to anchor tag links using jquery.
here is my code
function urlify(text) {
var urlRegex = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
return text.replace(urlRegex, function(url) {
return '' + url + '';
})
}
$("#queEditor").bind('input propertychange', function(){
var url = urlify($("#queEditor").text);
console.log(url);
});
But it's giving an error undefined function text. Could someone help me rectify this?
Since .text() is a function you need to use () when you want to invoke it.
$("#queEditor").text(); //Notice ()