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 11 July 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)
php - file_get_contents shows unexpected output while reading a file
I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...
-
I have an app which needs a login and a registration with SQLite. I have the database and a user can login and register. But i would like th...
-
I got an error in my Java program. I think this happens because of the constructor is not intialized properly. My Base class Program public ...
-
I would like to use enhanced REP MOVSB (ERMSB) to get a high bandwidth for a custom memcpy . ERMSB was introduced with the Ivy Bridge micro...
No comments:
Post a Comment