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 8198781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:01:29+00:00 2026-06-07T06:01:29+00:00

This is a jQuery variant of a script (it doesn’t work): <script language=javascript> $(div.post-content).each(function(){

  • 0

This is a jQuery variant of a script (it doesn’t work):

<script language="javascript">
$("div.post-content").each(function(){
    if($(this).innerHTML.indexOf("[/float]") != -1) {
        pattern= /\[float=(.*?)\]([^\[]*)\[\/float\]/gi
        $(this).html($(this).innerHTML.replace(pattern, "<span style='float: $1;'>$2</span>"))
    }
})
</script>

This is the pure Javascript variant (it works perfectly):

<script language="javascript">
posts=document.getElementsByTagName("div")
for(x in posts) if(posts[x].className=="post-content") {
    post = posts[x].innerHTML;
    if(post.indexOf("[/float]") != -1) {
        pattern = /\[float=(.*?)\]([^\[]*)\[\/float\]/gi
        posts[x].innerHTML = posts[x].innerHTML.replace(pattern, "<span style='float: $1;'>$2</span>")
    }
}
</script>

What this script does:

  1. It seeks out all divs with class post-content.
  2. It checks whether there’s a closing tag for bbcode.
  3. By using regular expression, it seeks out patterns of given bbcode tags.
  4. It replaces bbcode tags with html element.

I don’t know what I did wrong here…

  • 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-06-07T06:01:31+00:00Added an answer on June 7, 2026 at 6:01 am

    Don’t use innerHTML when using jQuery. It’s wrong when assigning a value (memory leaks), and a bad practice when reading a value. Use

    $(this).html()
    

    or, if you really want to,

    $(this)[0].innerHTML
    

    The jQuery object returns an array, that doesn’t have a innerHTML property. But then again, use .html() for a code more of the style of jQuery.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why doesn't this jQuery code work? $(document).ready(function () { $('currentPage').click(function() { $('myaccount').slideDown('slow', function() {
Using this jquery code: <a href=javascript:void(0) id=m1>Get Selected id's</a> jQuery(#m1).click( function() { var s;
I have this jQuery script that works fine: $(select).change(function () { var finalPrice =
This jQuery function is meant to post the value of num to a PHP
Given this jQuery: $('div.MvcFieldWrapper :input').focus(function() { $(this).closest('label.MvcDynamicFieldError').fadeOut(); }); And given this HTML: <div class=MvcFieldWrapper>
This jquery toggles two things. (1) A css class and (2) displaying a div.
I have this jquery function that works, except I need to add something. I
I have this jQuery code: $(document).ready(function() { $.ajax({ url: pages/+page+.php, cache: false }).done(function( html
In this jquery code: $(document).ready(function(){ $list = $(.channeList li); $list.click(function(){ var $this = $(this);
I found this HOT bit of jQuery that actually allows you to replicate font-variant:

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.