简体   繁体   中英

using a different style sheet on page load depending on radio buttons

I have been put in charge of a site for one of our clients that was built by an outside company. One of the additional requests is that she wants to be able to position an image on their news page either on the left, right or centred.

There is an administration system in place where the client can create a news article and add an image however I need to know if there is anyway I can change the image position on the 'news items' page depending on whether the left, right or centred radio button has been checked on the administration panels 'add a news item' page.

I think it is possible with Java but it's not something I have had to do before and am looking for a nudge in the right direction really.

I think it is possible with Java but the tutorials I have found show me how to change the css with Java on the current page but not on a different page.

Any advice would be much appreciated

Write 2 css classes, class1: for left alignment and class2: for right alignment. Suppose if there are 2 radio buttons. On click of each radio you can toggle value of class.

   $("#radioId1").click(function () {
          $('#para1').removeClass('class1');  
      $('#para1').addClass('class2');

    });




$("#radioId2").click(function () {

  $('#para1').removeClass('class2');
      $('#para1').addClass('class1');

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM