Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6945731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:28:25+00:00 2026-05-27T13:28:25+00:00

Is it possible to use jQuery to modify HTML plaintext? For example, in this

  • 0

Is it possible to use jQuery to modify HTML plaintext?

For example, in this specific case, if I have a time of 18:00 showing in plan HTML text, is it possible to have a drop down list with options for +1, +2, +3 and so forth, or -1, -2, -3 and so forth so that when one of these options is selected, the time changes to 17:00 or 19:00 or whatever depending on the option selected?

If this is possible, what kind of jQuery code would I use, and would there is any limitation? A demonstation on jsFiddle would be appreciated so I can see the code in action, if possible.

The time will be getting pulled from a database using PHP, but it would be displayed in plain HTML text with, perhaps, some CSS styling on it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:28:26+00:00Added an answer on May 27, 2026 at 1:28 pm

    So far as I can tell PHP has no part to play in this solution, since it’ll be client-side (given the JavaScript requirement), however one method, using jQuery with the following HTML snippet:

    <span id="time">18:00</span>
    <select name="modTime" id="modTime">
        <option value="-3">-3</option>
        <option value="-2">-2</option>
        <option value="-1">-1</option>
        <option value="0">0</option>
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
    </select>
    

    jQuery:

    var curTime = $('#time').text(),
        curTimeHH = parseInt(curTime.split(':')[0],10);
    $('#modTime').change(
        function(){
            var modifyBy = parseInt($(this).val(),10);
            curTimeHH = curTimeHH + modifyBy;
            $('#time').text(curTimeHH + ':00');
        });
    

    JS Fiddle demo.


    Edited in response to question from OP (in comments, below):

    …but it should always add or subtract relative to the original value, if that makes sense. And when you select “0” it should go back to what it originally was. Is that possible?

    Yeah, that’s possible; it’s all about making sure the original time is stored somewhere accessible (you could use just a regular JavaScript variable, but I’m choosing instead to store it in a HTML5 data-* attribute:

    var curTime = $('#time').text(),
        curTimeHH = parseInt(curTime.split(':')[0],10);
    $('#modTime').change(
        function(){
            $(this).attr('data-originalTime',curTime);
            var modifyBy = parseInt($(this).val(),10);
            curTimeHH = parseInt($(this).attr('data-originalTime'),10) + modifyBy;
            $('#time').text(curTimeHH + ':00');
        });
    

    JS Fiddle demo.

    References:

    • jQuery, from the jQuery API:
      • .attr().
      • .change().
      • .text().
    • JavaScript, from the Mozilla Developer Network’s JavaScript resource:
      • parseInt().
      • split().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to use jQuery on a new Window javascript object? Example: win
Is it possible to use jQuery's $.post function and have the cookies set in
I have only: <div> <textarea id=names></textarea> </div> I can't modify html. I can use
Is it possible to use jQuery in win32 application? I have seen interesting stuff
Is it possible to use jQuery.not() chained with jQuery.html() ? winner.not('a').html() Where winner is
I know it is possible to use jQuery to do something like: $('body').css('cursor','wait'); What
Is jQuery UI considered a jQuery Plugin? Is it possible to use jQuery UI
Is it possible to use a jQuery ajax call to perform Forms Authentication with
Is it possible to use SimpleModal (jquery plugin) with ASP.NET MVC? Since it has
Is it possible to restrict direct access to PHP file if I use jquery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.