jQuery html vs append

0 votes

Lets say I have an empty div:

<div id='myDiv'></div>

Is this:

$('#myDiv').html("<div id='mySecondDiv'></div>");

The same as:

var mySecondDiv=$("<div id='mySecondDiv'></div>");
$('#myDiv').append(mySecondDiv);

Aug 3 in Web Development by gaurav
• 17,580 points
8 views

1 answer to this question.

0 votes

You have the :hover pseudo on your CSS. While this exists, the behaviour persists.

You can add a .small-window class to your <html> tag and control it with that.

https://jsfiddle.net/9a1n8xtw/4/

$(window).on('resize', function() {
    isSmallWindow = $(this).width() < 768;
    if(isSmallWindow) {
        $('html').addClass('small-window');
    }else {
        $('html').removeClass('small-window');
    }
});

And the css

html:not(.small-window) .headline:hover + .content {
    display: block;
}
answered Aug 4 by rajatha
• 7,040 points

Related Questions In Web Development

0 votes
0 answers

How to add jQuery code into HTML Page

$(".icon-bg").click(function () { $(".btn").toggleClass("active"); ...READ MORE

Jun 29 in Web Development by gaurav
• 17,580 points
21 views
0 votes
0 answers

JQuery only append to child

Please help me to understand why it's ...READ MORE

Jul 19 in Web Development by gaurav
• 17,580 points
5 views
0 votes
0 answers
0 votes
1 answer

Why does the WebView html in my Mac app refuse to load JQuery or any external script?

I changed https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js to http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js and now it works. If anyone ...READ MORE

answered Aug 5 in Web Development by rajatha
• 7,040 points
10 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,500 points
307 views
0 votes
1 answer

Error: Global Variable is not accessable to local function

Hey kartik, A variable declared outside a function has a ...READ MORE

answered Feb 19, 2020 in PHP by Niroj
• 82,740 points
282 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,740 points
8,825 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,740 points
15,808 views
0 votes
1 answer

jQuery vs. javascript?

JavaScript is an independent language and can ...READ MORE

answered Jun 30 in Web Development by rajatha
• 7,040 points
14 views
0 votes
1 answer

jQuery .val() vs .attr("value")

There is a big difference between an objects properties and an ...READ MORE

answered Aug 5 in Web Development by rajatha
• 7,040 points
7 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP