jquery .show() from only the selected div
Tags: jquery,html,css
Problem :
I have a textarea
for commenting on various objects. The textarea
are initially hidden, and clicked on the comment link as commentbn
it shows up which is what I want. But, the problem is that, when I click any of the commentbtn
, all the the textarea
shows up! Which I don't want. I just want the textarea of the particular subject. Suppose I want the comment to show up from topic1, then only the comment of the topic1 should appear, and not of topic2 or topic3 e.t.c. . How do I do that? Any help or guidance will be greatly appreciated. Thank you.
html:
<div class="video">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<img src="image/youtube.jpg">
<div class="general">
<a href="#">Like</a> <a href="#" class="nos">27</a>
<a href="#" class="commentbtn">Comment</a> <a href="#" class="nos">27</a>
<a href="#">Share</a> <a href="#" class="nos">27</a>
<br>
<textarea class="comment"></textarea>
</div>
</div>
<div class="forum">
<a class="QA L" href="#">Q</a>
<a class="QA R" href="#">Photography</a>
<a class="QA R" href="#">Fashion and Style</a>
<a class="QA R" href="#">Design</a>
<p class="clear_both"></p>
<a href="#">What is the most amazing photograph you have ever taken?</a>
<img src="image/forum1.jpg">
<div class="general">
<a href="#">Like</a> <a href="#" class="nos">27</a>
<a href="#" class="commentbtn">Comment</a> <a href="#" class="nos">27</a>
<a href="#">Share</a> <a href="#" class="nos">27</a>
<br>
<textarea class="comment"></textarea>
</div>
</div>
css:
#activity .comment {
display: none;
width: 502px;
max-width: 502px;
padding-bottom: 0px;
border: 1px solid #dbdbdb;
height: 17px;
padding:5px;
overflow: auto;
outline: none;
box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
js:
<script type="text/javascript">
$(function() {
$('.commentbtn').click(function() {
$('.comment').show();
return false;
});
});
</script>
Solution :
You need to target the sibling comment
element of the clicked button, instead you are targeting all comment
elements in the page
$(function() {
$('.commentbtn').click(function() {
$(this).siblings('.comment').show();
return false;
});
});
CSS Howto..
Look at the diagram. Create a container to represent the dark blue/purple outline. Give it a size. Centre it. Arrange the three side-by-side elements inside that container....
You need to increase the border thickness ----> border-left: 103px solid transparent; and border-right: 100px solid transparent; and do some positioning adjustments. For displaying a specific region of an image,...
hmm maybe i'm not understanding this correctly but why don't you make the usercontrol finds the master's label (findcontrol); check the values; and then display the correct image. the way...
Not quite sure what you want to accomplish - a bit more details would help but here is a shot... So here is an example that 'inserts' the drag into...
I think you want li:hover { background-color: New Color; } Here is a really simple dropdown menu I made Html <div id="newsletter" class="navigation"> <span style="display:block;" id="newsletterMain" href="index.html">Newsletter</span> <a style="margin-top:19px; border-top:...
Give the p left and right margin auto margins. .separate p{ border:1px solid lightgray; margin:0 auto; width:50%; } ...
I got what u wanted...Basically here's what i did Removed the inline css style from button and anchor tag. Removed the width property. Added class bt1 and bt2 to the...
Have you heard of media queries? This is a technique deployed through CSS that allows you to affect the styling of elements based on the width and height of the...
Researching I've found an answer to my question. We need to use the rotateY attribute for the -webkit-transform CSS property. .imageRotateHorizontal{ -moz-animation: spinHorizontal .8s infinite linear; -o-animation: spinHorizontal .8s infinite...
<div style="color:#ffffff;">Your text next to your form. </div> ...
The code you are looking for: .nav > li > a:hover, .nav > li > a:focus { text-decoration: none; background-color: #EEE; } Super simple, fix: <link bootstrap /> <link custom...
Used to this find your td and define your css only .done class not tr .done $("#myTable tr").on('click', function() { $(this).find('td').addClass("done"); }); $("#myTable tr").on('click', function() { $(this).find('td').addClass("done"); }); table {...
I suggest you look into localStorage
the use of display: inline-block; on the ul.base is the cause. when you use that it formats an element like it were inline (it only formats the actual content of...
I'd recommend you to try to switch from Guriddo jqGrid JS 5.1.0 to free jqGrid 4.13.3, which I develop. Starting with version 4.10.0 (of free jqGrid) I rewrote many parts...
It appears that to following works... .ui-widget#tabdiv :focus { border-style: inset !important; border-width: 3px !important; } Thanks!...
When you use .wrap :not(.section) .text, this is what you're telling the browser: Look for an element with a class of .text which lives inside an element that does not...
To make this simple If you look at the HTML from http://getbootstrap.com/javascript/#carousel Copy the first one and add some Razor, this should generate a Carousel for you. @model List<YOUR_MODEL_NAME> @{var...
I had a similar problem; you can either set up IIS to add a content-expiration header for the CSS files so they never get cached, or you can use the...
Use parenteses .css() and height inside a quote. $(document).ready(function () { if(window.location.href.indexOf("invt") > -1) { $("#promo-carriage").css("height", "40px"); } }); ...
Just use the :not() selector (the * is implied): :not(button) { margin: 0; /* applied to all elements except <button> */ } Read more at https://developer.mozilla.org/en/docs/Web/CSS/:not...
Your doctype should be <!DOCTYPE html> This works across all browsers and should be added to the top of your HTML. I noticed that you aren't declaring a value on...
You can add the following rules at your css file (this is not efficient): a[href^="http://i.imgur.com"] { color: red !important; } It is like a regexp, and it is not efficient...
The easiest way is indeed to have an FTP access and edit the blog's theme directly (in /wp-content/themes/nameofyourtheme. Otherwise, you can also do it from the Admin panel. Go to...
It's messy, but throwing in some CSS animations did the job. http://jsfiddle.net/Pd426/1/ The new CSS: #box{ -moz-border-radius:15px; border-radius:15px; width:1px; height:1px; background:#D8D8D8; border:2px solid black; position: relative; margin-left:100px; margin-top:150px; transform:rotate(0deg); -ms-transform:rotate(0deg);...
You need to add position:relative to .container-fluid
If this the full code you are not making submit_hit to true, i think its need to set true before form.submit() so the js for div1/div2 execute. $("#loader1").show(); submit_hit =...
The box-shadow property supports a keyword called "inset" for box-shadow inside a box. E.g. box-shadow: inset 0 -10px 5px 5px hsl(0, 0%, 90%); (btw, no need for the prefixes, see...
You should look up the transform-origin property. References here and here. The transform-origin property is used to change the position of the origin of transformation of an element. Change: .toTransform,...
This will do what you want. Markup <body> <div id="top">top</div> <div id="container"> <div id="content"> content </div> <div id="right"> right </div> <br style="clear:both" /> </div> <div id="bottom">bottom</div> </body> CSS #container {border:1px...