/    Sign up×
Community /Pin to ProfileBookmark

Changing four <li> – entries each row to two or three

I am going to list the code first and explanation later.

I have this HTML-Code

[code=html] <div class=”develop-bl”> <i></i>
<ul>
<li>
<a href=”#”>entry</a>
</li>
<li>
<a href=”#”>entry</a>
</li>
<li>
<a href=”#”>entry</a>
</li>
<li>
<a href=”#”>entry</a>
</li>
<li>
<a href=”#”>entry</a>
</li>
<li>
<a href=”#”>entry</a>
</li>
<li>
<a href=”#”>entry</a>
</li>
<li>
<a href=”#”>entry</a>
</li>
</ul>
</div>[/code]

and this Javascript-Code

[CODE] var y = $ (‘.develop-bl’).find(‘li’).length;
if(y%4>=0) {
$(‘.develop-bl li:nth-child(4n+4)’).css(‘margin-right’,’0px’);}
if(y%4==0) {
$(‘.develop-bl li’).slice(-4).css(‘border-bottom’,’none’);}
else {
var y = $(‘.develop-bl’).find(‘li’).length;
var b = y/4;
var values = b.toString().split(‘.’);
var v2 = parseFloat(values[1]);
if(values[1]==5) {
$(‘.develop-bl li’).slice(-2).css(‘border-bottom’,’none’);}
else{
var i = values[1]*0.04;
$(‘.develop-bl li’).slice(-i).css(‘border-bottom’,’none’);}
};[/CODE]

The goal is to have 4 li-entries each row, which this code accomplishes. What needs to be changed to have 3 or 2 entries each row?

to post a comment
JavaScript

1 Comments(s)

×

Success!

Help @Okzident spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...