- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Probably a simple answer but…
I am a newbie to javascript and I am using jquery for some simple sliding navigation menus for a mobile site I am developing. I have set up a unique style sheet for mobile browsers and am using media queries to detect the mobile devices.
The problem I am having is that I need to insert some new html tags into the document using javascript but don’t know how this is done. I currently have an external javascript file that I am referencing that can be viewed here:
http://www.corvairflair.com/optinose-mobi/test.js
I kind of know how to find the specific id I am targeting using js, but after that I am lost. If anyone understands my request please chime in.
Thanks
Mike
$(document).getElementById ('#footer p').style.border = "solid 5px #c0c0c0";
You are mixing up javascript and jQuery.
Your javascript should probably look something like this:
$(document).ready(function() {
$('.navigation li ul, .fade img').hide();
$('.navigation li a').click(function(){
$(this).siblings('ul').slideToggle();
return false;
});
$('#footer p').css('border', '5px solid #c0c0c0');
});
I haven’t seen the html, but I think that should work.
In order to add html after an element. You would do this:
$('#header').after('This is an example');
Thanks for the clarification. I told you I was a noob :-)
If I wanted to add an html element after the #footer p would I do this?
$('#footer p').after(Drop this line of copy in after the p tag
Thanks
Mike
@miker1961, Close. Your syntax is a little off. It would go like this:
$('#footer p').after('Drop this line of copy in after the p tag
');
Never forget the quotes.