0

Here is a ul li list. I generate this list using js file. I would like to those list lift-aligned. But it doesn't work. When I write this code only HTML it left-aligned. Is there diffrence when using js file?

app.js

 if (name.search(expression) != -1 || location.search(expression) != -1) {
              $(`.resultUl[data-ref="${ref}"]`).append(
            `<li 
                class="list-group-item link-class list-item"
                data-name="${name}"
                data-code="${code}"
                data-location="${location}"
              >

              ${name}
              <span class="text-muted">${location}</span>
           </li>
           `
          );
        }
      });
machagr
  • 77
  • 1
  • 10
  • You will have to re-apply the css to newly appended html due to the explanation shown here https://stackoverflow.com/q/20738850/10634638 – estinamir Feb 16 '19 at 05:02
  • Dear @bestinamir Thank you for answering me. I add this to css but it's still doesn't work... What am I missing? Do I need something to js code? CSS code -> .list-group-item { padding-left: 0; } – machagr Feb 16 '19 at 05:20
  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and _the **shortest code necessary to reproduce it** in the question itself_. See: How to create a [mcve]. – Asons Feb 16 '19 at 09:16
  • @bestinamir No, no need to re-apply CSS styles, they only need to be declared/used correctly, syntax-wise. – Asons Feb 16 '19 at 09:18
  • @LGSon the question is incomplete... it got here due a discussion in a room where I asked to the OP the post new questions if needed for further assistance if there is something else related to the previous issue. The OP should have posted the full code in the first place, and specify exactly the issue with the code at hand. – Sabbin Feb 16 '19 at 09:58

2 Answers2

2

The answer from @Adim Victor was wright but you had other issues at hand with your code...

.list-item {
   text-align : left; 
}

Here is the working Fiddle based on your code

Please from now on post the full code so other people can assist you better

Sabbin
  • 2,215
  • 1
  • 17
  • 34
0

You have to style all .list-group-item with CSS. Try this..

.list-group-item {
   text-align : left; 
}
Adim Victor
  • 104
  • 6