dom-manipulation

Run a function when a DOM element is created

Hi folks, I want to bind an event to a certain class and ID for when matching objects are created in the DOM. I am doing this as I have some jQuery code in an ASP UpdatePanel, which causes the DOM to be re-loaded on its partial postback. I have reset the events with live(), however I need to call a 2 line initialisation function as soo...

javascript dom-injected elements don't pick up css-styling in IE

I'm having the weird problem that after having javascript inject some dom-elements the css-rules defined for those elements are not obeyed in IE7(i.e: styling for these elements doesn't happen). (firefox and chrome work fine, others not tested) Things I tried: - cleared the cache - no other css-rule takes precedence (no 'more-specific...

jQuery to get innerHTML not working on a HTMLFontElement object...

I have jQuery to select all font elements that are children of the element with id="right" within the html stored in the var html... when I do an alert to see how many elements it gets: alert($("#right > font", html).length); it gives me an alert of: 5 but when I try any of the following, I don't get any alerts... alert($("#right > ...

jQuery filename manipulation

Hi all, I am trying to do a fancy blur/fade effect (which means i need 2 images) but I only want to load 1 in the HTML (in case js is not active) and add the other filename via jQuery (copying and renaming the file/src) The pure html is along the lines of: <div id="work"> <div> <img src="css/images/abc1.jpg" width="360" height="227...

.before method adds unexpected close tags

I have a table in my markup on which I want to add some divs before and efter like this: <div class="widebox"> <div class="widebox-header">Opret/rediger bruger</div> <div class="widebox-middle"> <table id="Table3"></table> </div> <div class="widebox-bottom"></div> </div> I'm trying to do this with jQuery, like this: $('#Table3').befo...

Is there an object in C# that allows for easy management of HTML DOM?

Hi, If I have a string that contains the html from a page I just got returned from an HTTP Post, how can I turn that into something that will let me easily traverse the DOM? I figured HtmlDocument object would make sense, but it has no constructor. Are there any types that allow for easy management of HTML DOM? Thanks, Matt ...

Which is better: string html generation or jquery DOM element creation?

Ok, I'm rewriting some vanilla JS functions in my current project, and I'm at a point where there's a lot of HTML being generated for tooltips etc. My question is, is it better/preferred to do this: var html = '<div><span>Some More Stuff</span></div>'; if (someCondition) { html += '<div>Some Conditional Content</div>'; } $('#parent...

manipulate variable made up of html before adding it to the dom (new in jQuery 1.4???)

I thought I had seen this in the first announcement of jQuery 1.4, but can't seem to find anything now. I have a calendar table which is built dynamically from a json ajax response. The table is built in a variable called putHtml. Currently, once the table is added to the DOM, I run a showEvents function which takes each event and add...

jquery - dom manipulation

I would like to show in dialog all elements with specific class. The dialog should hide the rest of the page. So for example: On this SO page I want to show all elements with class="user-info". Those elements would be shown in dialog with same width and height and same css and everything else would be hidden. It would be like cutting th...

How do I ensure AJAX still works after content moved from iFrame through DOM manipulation

After submitting an iFrame, content with AJAX enabled functions is returned and everything works. Once I move the content out from the iFrame to the main page through DOM manipulation and remove the iFrame, AJAX stops working. How can I make it work? I grab the body content of the iFrame and move it to an outside element through .inne...

mootools html and css maniplation help

Hello, I have the following HTML <div class="goto_step3"> <a href="<?= $this->sitePfx ?>/cart/paypal/" id="js_checkout_now" class="arrow">Checkout &amp; Pay</a> <? if($this->discountCodeErrorMessage): ?> <p class="error discountError"><?= $this->discountCodeErrorMessage ?></p> <? endif; ?> <div class="discountCode fncFixedHeight <?=...

Help with manipulating child/parent elements with jQuery

Currently I have this JQuery script var img = $(this); img.wrap('<div class="photo"></div>'); img.parent().append("<p>" + img.attr("alt") + "</p>"); which successfully turns the following: <img src="photo.jpg" alt="caption"> into this <div class="photo"> <img src="photos.jpg" alt="caption"/> <p>caption</p> </div...

[jQuery] Prepend and Append at the same time

$('.testimonials blockquote p') .prepend('<span class="quo ldquo">&ldquo;</span>') .append('<span class="quo rdquo">&rdquo;</span>'); ...prepends and appends TWICE. How do I prepend ldquo + whatever content inside the p + rdquo? Thanks! ...

jquery insert a html block so it starts before the target and ends after the target - is this possible?

Hi all, I understand you can add insert blocks of html before and after a target using before(), insertBefore(), after() and insertAfter(). I tried to do something similar to this <script type="text/javascript"> $(document).ready(function(){ $("p").before("<div class='myContainer'>"); $("p").after("</div>"); })...

remove an element that is before the selected element

Hi, I'm doing some form error handling/manipulation and I have the need to remove an error div that is before the input that is being validated... HTML: I'd like to remove the div.textError if the input field is validated. I tried this... $(this).before('<div class="textError"></div>').remove('<div class="textError"></div>'); an...

jquery ajax method being repeated even though click event not correct

Hi There, I have some ajax on my web page, that is triggered via a click event, the javascript in question looks like this, $('.career_select .selectitems').click(function(){ var selectedCareer = $(this).attr('id'); $.ajax({ type: 'POST', url: '/roadmap/step_two', data: 'career_choic...

Why won't this div add a class in jQuery?

I make a $.get call to my db and it returns some HTML (data): $.get(url, null, function(data) { The HTML it returns is something like this: <div id="1234" class="myclass">..more html..</div> In my callback function, I try to add a class to it (based on some conditionals that I have tested are successfully being reached) like so: i...

Prevent firebug from manipulating DOM

Is there a way to prevent programs like Firebug from manipulating the DOM of a page. I've noticed that you can simply delete thing like ads that are paid for by other companies. Is there a way for the page to stop it? ...

Change the tag but keep the attributes and content -- jQuery/Javascript

Hello! How can you get: <a href="page.html" class="class1 class2" id="thisid">Text</a> changed to <p href="page.html" class="class1 class2" id="thisid">Text</p> I'm familiar with jQuery's replaceWith but that doesn't keep attributes/content as far as I know. Note: Why would p have a href? Cuz I need to change p back to a on a...

Manipulating hidden div's

Ok, so i have a few <div1> elements with static content inside of them. Then if you hover over the <div1> another <div2> pops up over top of it. (note: how this happens is the "display" property changes from "none" to "block") This <div2> has data that is relevant to <div1>. It populates dynamically based on the <div1> that you over o...