开发者

How can I reposition a DIV with jQuery? [closed]

开发者 https://www.devze.com 2023-04-11 20:13 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I'm trying to use AJAX (not jQuery).... I basically have this going on.

Content A Title
Content A Full
HR
Content B Teaser
Content C Teaser
Content D Teaser

Html/CSS Example of State A

I have the before and after CSS, but I'm having trouble finding example code that actually alters CSS. Instead, I'm finding tricks like 'adding a class' and stuff that people use to simply hack the CSS. So, I think maybe I'm starting in the wrong place.

I'm using Php 5 and MySQL, if you want to be really helpful. I'm not worried about that, though, as I'm presently working on it, myself. What I'm SUPER interested in is figuring out how to create this, without having the page refresh:

Content C Title
Content C Full
HR
Content A Teaser
Conte开发者_运维问答nt B Teaser
Content D Teaser

HTML/CSS Example of State B


I think you are looking for something like THIS. It is possible with Javascript to copy DOM elements or move them... Read something about cloning and deleting nodes with JS(clone node method described HERE)


You can use [element.setAttribute][1]("*style*", "*value*"). You can target the CSS [document.querySelector][2]("*target*") to select the div class or id or what-have-you.

You can use jQuery, like so: $('*target*').css('*style*', '*value*').

There doesn't seem to be a short-hand AJAX equivalent.

Sample arguments:

Style: "align", "background-color".
Value: "center", "blue".

Target: "#myDiv", ".myDiv", "p"
0

精彩评论

暂无评论...
验证码 换一张
取 消