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, 2022 in Web Development by gaurav
• 23,260 points
351 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, 2022 by rajatha
• 7,640 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, 2022 in Web Development by gaurav
• 23,260 points
310 views
0 votes
0 answers

JQuery only append to child

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

Jul 19, 2022 in Web Development by gaurav
• 23,260 points
214 views
0 votes
0 answers

how can i get the url of the content( home.html) in adress bar by jquery load() function?

I am using jquery load() function to ...READ MORE

Jul 28, 2022 in Web Development by gaurav
• 23,260 points
375 views
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, 2022 in Web Development by rajatha
• 7,640 points
526 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,510 points
973 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,880 points
826 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,880 points
14,124 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,880 points
22,370 views
0 votes
1 answer

jQuery vs. javascript?

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

answered Jun 30, 2022 in Web Development by rajatha
• 7,640 points
201 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, 2022 in Web Development by rajatha
• 7,640 points
821 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP