Reputation: 2961
I cannot get this simple append working. I'm trying to add two break tags AFTER the first Image.
This is a link
<script type="text/javascript">
$(document).ready(function(){
$('.photosize').find('img:first').append('<br/><br/>');
});
</script>
Upvotes: 3
Views: 4644
Reputation: 18344
Do this (it's tested and works):
$('.photosize img').first().after('<br/><br/>');
Hope this helps. Cheers
Upvotes: 0
Reputation: 19609
This already works, with caveats:
1) When you call $.append()
it appends the string to the innerHTML of the element you are appending to. So for this instance it will add two line breaks to the innerHTML of the image element. Try using $.after()
instead:
$('.photosize').find('img:first').after('<br/><br/>');
2) The :first
selector doesn't work in many (if not all) versions of IE. You can fix this by selecting it using an ID or class instead of the pseudo class :first
Upvotes: 0