[JAVASCRIPT][CSS] refer to the current question, not its ID#

More
4 years 1 month ago - 4 years 1 month ago #95535 by Qat
Qat created the topic: [JAVASCRIPT][CSS] refer to the current question, not its ID#
Hello everyone.

My javascript/css knowledge is poor, and I couldn't find the answer to my question after 15 minutes searching, so I turn to you guys.

I found out how to change the looks of a specific question through javascript. I enter the following code inside the question source. So far, so good.
<script type="text/javascript" charset="utf-8">
 $(document).ready(function(){
  $('#question396 .survey-question').css({
    'border-bottom':'0px',
    'margin-bottom':'-10px'
   }); 
 });
</script>

I want to do this for several question, and I'd like to make my code more portable : remove the reference to the specific question (#question396). Since the code is inserted inside the question code, is there a way to refer to the current question ?

I hope I'm clear enough.
Last Edit: 4 years 1 month ago by Qat.

Please Log in to join the conversation.

More
4 years 1 month ago #95547 by tpartner
tpartner replied the topic: [JAVASCRIPT][CSS] refer to the current question, not its ID#
Try:
<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
		$('#question{QID} .survey-question').css({
			'border-bottom':'0px',
			'margin-bottom':'-10px'
		}); 
	});
</script>

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
4 years 1 month ago #95554 by Qat
Qat replied the topic: [SOLVED] - [JAVASCRIPT][CSS] refer to the current question, not its ID#
It works. Simple and elegant.

Thanks a lot for your useful and prompt reply !

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now