I’ve got a function that appends a I need to see if a Here is my code: This seems pretty straightforward but I’m getting the error “Unexpected end of file while searching for class name”. I have no clue what that means. What’s more is that I want to be able to delete this element if I close it out which should then remove the Here is the code for that: I added Answer You can use The full version: Or, the non-jQuery version for this part (since it's an ID):name. That variable is then used as the id of the appended element.id with name already exists before I append the element but I don’t know how to find this.$("li.friend").live('click', function() {
name = $(this).text();
// if-statement checking for existence of
// If
$("div#chatbar").append("
// Else
alert('this record already exists');
});if (document.getElementById(name)) {
$("div#" + name).css({bottom: '30px'});
} else {
$("div#page-content div#chatbar").append("
}div id [name] from the document but .remove() does not do this.$(".mini-close").live('click', function(){
$(this).parent().remove();
});.mini-close to the append function as a child of .labels so there was a way to close out of the appended .mini-close and attempting to click the same name again from li.friends it still finds the div id [name] and returns the first part of my if statement.
.length after the selector to see if it matched any elements, like this:if($("#" + name).length == 0) {
//it doesn't exist
}$("li.friend").live('click', function(){
name = $(this).text();
if($("#" + name).length == 0) {
$("div#chatbar").append("
} else {
alert('this record already exists');
}
});$("li.friend").live('click', function(){
name = $(this).text();
if(document.getElementById(name) == null) {
$("div#chatbar").append("
} else {
alert('this record already exists');
}
});
Thursday, July 11, 2019
javascript - How to find if div with specific id exists in jQuery?
to an element on click. The function gets the text of the clicked element and assigns it to a variable called
should go here
does not exist, then append element
" + name + "
");" + name + "
"); if needed. After clicking
" + name + "
");" + name + "
");
Subscribe to:
Post Comments (Atom)
plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV
In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...
-
When the left part is an object instance, you use -> . Otherwise, you use :: . This means that -> is mostly used to access instance m...
-
i've started to create my website, but now i have few doubts. I've searched, that MySqli object oriented is good to use beca...
-
I've been asked to update some Excel 2003 macros, but the VBA projects are password protected, and it seems there's a lack of docume...
No comments:
Post a Comment